aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures/company.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-07 12:25:01 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-07 12:25:01 +0000
commitea759cb76161a7a0003c3cd3b38a8a125a99af3c (patch)
tree468f4ba7ea4f4b3cb778906fa1c9ebb680f4944f /activerecord/test/fixtures/company.rb
parent465e0c0c2635588927ca707e6220cd7f232b3f17 (diff)
downloadrails-ea759cb76161a7a0003c3cd3b38a8a125a99af3c.tar.gz
rails-ea759cb76161a7a0003c3cd3b38a8a125a99af3c.tar.bz2
rails-ea759cb76161a7a0003c3cd3b38a8a125a99af3c.zip
Added counter_sql option for has_many associations [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@68 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures/company.rb')
-rwxr-xr-xactiverecord/test/fixtures/company.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/fixtures/company.rb b/activerecord/test/fixtures/company.rb
index b5ee055948..7d9a6053d4 100755
--- a/activerecord/test/fixtures/company.rb
+++ b/activerecord/test/fixtures/company.rb
@@ -9,6 +9,12 @@ class Firm < Company
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
+ has_many :clients_using_counter_sql, :class_name => "Client",
+ :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
+ :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}'
+ has_many :clients_using_zero_counter_sql, :class_name => "Client",
+ :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
+ :counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}'
has_one :account, :dependent => true
end