diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/sanitization.rb | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index bc483c1825..36fc08e6ad 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -1,14 +1,14 @@ module ActiveRecord class PredicateBuilder # :nodoc: - def self.build_from_hash(engine, attributes, default_table) + def self.build_from_hash(klass, attributes, default_table) queries = [] attributes.each do |column, value| table = default_table if value.is_a?(Hash) - table = Arel::Table.new(column, engine) - association = engine.reflect_on_association(column.to_sym) + table = Arel::Table.new(column, default_table.engine) + association = klass.reflect_on_association(column.to_sym) value.each do |k, v| queries.concat expand(association && association.klass, table, k, v) @@ -18,10 +18,10 @@ module ActiveRecord if column.include?('.') table_name, column = column.split('.', 2) - table = Arel::Table.new(table_name, engine) + table = Arel::Table.new(table_name, default_table.engine) end - queries.concat expand(engine, table, column, value) + queries.concat expand(klass, table, column, value) end end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 00cdaf686f..3c59bd8a68 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -708,7 +708,7 @@ module ActiveRecord [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))] when Hash attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts) - PredicateBuilder.build_from_hash(table.engine, attributes, table) + PredicateBuilder.build_from_hash(klass, attributes, table) else [opts] end diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb index 5c74c07ad1..42b4cff4b8 100644 --- a/activerecord/lib/active_record/sanitization.rb +++ b/activerecord/lib/active_record/sanitization.rb @@ -88,8 +88,8 @@ module ActiveRecord def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name) attrs = expand_hash_conditions_for_aggregates(attrs) - table = Arel::Table.new(table_name).alias(default_table_name) - PredicateBuilder.build_from_hash(arel_engine, attrs, table).map { |b| + table = Arel::Table.new(table_name, arel_engine).alias(default_table_name) + PredicateBuilder.build_from_hash(self.class, attrs, table).map { |b| connection.visitor.accept b }.join(' AND ') end |