diff options
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 2860a30f99..4c49d3eb81 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -29,24 +29,8 @@ module ActiveRecord end def create_binds(attributes) - result = attributes.dup - binds = [] - - attributes.each do |column_name, value| - case value - when String, Integer, ActiveRecord::StatementCache::Substitute - result[column_name] = Arel::Nodes::BindParam.new - binds.push([table.column(column_name), value]) - when Hash - attrs, bvs = associated_predicate_builder(column_name).create_binds(value) - result[column_name] = attrs - binds += bvs - when Relation - binds += value.arel.bind_values + value.bind_values - end - end - - [result, binds] + attributes = convert_dot_notation_to_hash(attributes.stringify_keys) + create_binds_for_hash(attributes) end def expand(column, value) @@ -108,6 +92,28 @@ module ActiveRecord end end + + def create_binds_for_hash(attributes) + result = attributes.dup + binds = [] + + attributes.each do |column_name, value| + case value + when String, Integer, ActiveRecord::StatementCache::Substitute + result[column_name] = Arel::Nodes::BindParam.new + binds.push([table.column(column_name), value]) + when Hash + attrs, bvs = associated_predicate_builder(column_name).create_binds_for_hash(value) + result[column_name] = attrs + binds += bvs + when Relation + binds += value.arel.bind_values + value.bind_values + end + end + + [result, binds] + end + private def associated_predicate_builder(association_name) |