diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-22 13:35:42 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-22 13:35:42 +0000 |
commit | dbe8a26d7d22215054fc3630be95b81a16512fb8 (patch) | |
tree | bcec750430d326595b32b4cab999a16d01cc7642 /activerecord/lib | |
parent | 91eaeb280385d8423d8ec6f7097c9e1a19deb131 (diff) | |
download | rails-dbe8a26d7d22215054fc3630be95b81a16512fb8.tar.gz rails-dbe8a26d7d22215054fc3630be95b81a16512fb8.tar.bz2 rails-dbe8a26d7d22215054fc3630be95b81a16512fb8.zip |
Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 1d8441e6f8..bca52d61d0 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -14,7 +14,8 @@ module ActiveRecord if options[:counter_sql] @counter_sql = interpolate_sql(options[:counter_sql]) elsif options[:finder_sql] - @counter_sql = options[:counter_sql] = @finder_sql.gsub(/SELECT (.*) FROM/i, "SELECT COUNT(*) FROM") + options[:counter_sql] = options[:finder_sql].gsub(/SELECT (.*) FROM/i, "SELECT COUNT(*) FROM") + @counter_sql = interpolate_sql(options[:counter_sql]) else @counter_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}#{@conditions ? " AND " + interpolate_sql(@conditions) : ""}" end |