diff options
author | Will Bryant <will.bryant@gmail.com> | 2008-09-24 17:00:35 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-09-29 17:49:44 +0200 |
commit | 35d731ef0aaf1b6103121bb2c2d21f5b17c26b3c (patch) | |
tree | 16b8c952117f2bf75e78a97a9dd00ad2bc4cf873 /activerecord/lib | |
parent | 8233f8314ba00838e8ef6b2d95cdfb7d58c8dece (diff) | |
download | rails-35d731ef0aaf1b6103121bb2c2d21f5b17c26b3c.tar.gz rails-35d731ef0aaf1b6103121bb2c2d21f5b17c26b3c.tar.bz2 rails-35d731ef0aaf1b6103121bb2c2d21f5b17c26b3c.zip |
fix eager loading's :condition sanitizing expanding against the wrong table
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index c60850fc77..284dc7dca0 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -96,7 +96,7 @@ module ActiveRecord options = reflection.options conditions = "t0.#{reflection.primary_key_name} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(options, preload_options) + conditions << append_conditions(reflection, preload_options) associated_records = reflection.klass.find(:all, :conditions => [conditions, ids], :include => options[:include], @@ -233,7 +233,7 @@ module ActiveRecord end end conditions = "#{table_name}.#{connection.quote_column_name(primary_key)} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(options, preload_options) + conditions << append_conditions(reflection, preload_options) associated_records = klass.find(:all, :conditions => [conditions, ids], :include => options[:include], :select => options[:select], @@ -254,7 +254,7 @@ module ActiveRecord conditions = "#{reflection.klass.quoted_table_name}.#{foreign_key} #{in_or_equals_for_ids(ids)}" end - conditions << append_conditions(options, preload_options) + conditions << append_conditions(reflection, preload_options) reflection.klass.find(:all, :select => (preload_options[:select] || options[:select] || "#{table_name}.*"), @@ -270,9 +270,9 @@ module ActiveRecord instance_eval("%@#{sql.gsub('@', '\@')}@") end - def append_conditions(options, preload_options) + def append_conditions(reflection, preload_options) sql = "" - sql << " AND (#{interpolate_sql_for_preload(sanitize_sql(options[:conditions]))})" if options[:conditions] + sql << " AND (#{interpolate_sql_for_preload(reflection.sanitized_conditions)})" if reflection.sanitized_conditions sql << " AND (#{sanitize_sql preload_options[:conditions]})" if preload_options[:conditions] sql end |