diff options
Diffstat (limited to 'activerecord')
3 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index ddb9d683d8..817caebc8f 100644 --- a/activerecord/CHANGELOG +++ b/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. diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 378fc79949..1152846df2 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -14,7 +14,7 @@ module ActiveRecord "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 diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 795eddd511..f2652f55cc 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -9,7 +9,7 @@ module ActiveRecord @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] |