Skip to content

Commit

Permalink
Fixed that conditions in has_many and has_and_belongs_to_many should …
Browse files Browse the repository at this point in the history
…be interpolated just like the finder_sql is

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@344 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jan 7, 2005
1 parent 98c02b9 commit b64004f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is

* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name

* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag.
Expand Down
Expand Up @@ -14,7 +14,7 @@ def initialize(owner, association_name, association_class_name, association_clas
"SELECT t.*, j.* FROM #{association_table_name} t, #{@join_table} j " +
"WHERE t.#{@association_class.primary_key} = j.#{@association_foreign_key} AND " +
"j.#{association_class_primary_key_name} = #{@owner.quoted_id} " +
(options[:conditions] ? " AND " + options[:conditions] : "") + " " +
(options[:conditions] ? " AND " + interpolate_sql(options[:conditions]) : "") + " " +
"ORDER BY #{@order}"
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ def initialize(owner, association_name, association_class_name, association_clas
@finder_sql = interpolate_sql(options[:finder_sql])
else
@finder_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}"
@finder_sql << " AND #{@conditions}" if @conditions
@finder_sql << " AND #{interpolate_sql(@conditions)}" if @conditions
end

if options[:counter_sql]
Expand Down

0 comments on commit b64004f

Please sign in to comment.