@@ -72,35 +72,6 @@ def expand_hash_conditions_for_aggregates(attrs)
7272 expanded_attrs
7373 end
7474
75- # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
76- # { name: "foo'bar", group_id: 4 }
77- # # => "name='foo''bar' and group_id= 4"
78- # { status: nil, group_id: [1,2,3] }
79- # # => "status IS NULL and group_id IN (1,2,3)"
80- # { age: 13..18 }
81- # # => "age BETWEEN 13 AND 18"
82- # { 'other_records.id' => 7 }
83- # # => "`other_records`.`id` = 7"
84- # { other_records: { id: 7 } }
85- # # => "`other_records`.`id` = 7"
86- # And for value objects on a composed_of relationship:
87- # { address: Address.new("123 abc st.", "chicago") }
88- # # => "address_street='123 abc st.' and address_city='chicago'"
89- def sanitize_sql_hash_for_conditions ( attrs , default_table_name = self . table_name )
90- table = Arel ::Table . new ( table_name ) . alias ( default_table_name )
91- predicate_builder = PredicateBuilder . new ( TableMetadata . new ( self , table ) )
92- ActiveSupport ::Deprecation . warn ( <<-EOWARN )
93- sanitize_sql_hash_for_conditions is deprecated, and will be removed in Rails 5.0
94- EOWARN
95- attrs = predicate_builder . resolve_column_aliases ( attrs )
96- attrs = expand_hash_conditions_for_aggregates ( attrs )
97-
98- predicate_builder . build_from_hash ( attrs ) . map { |b |
99- connection . visitor . compile b
100- } . join ( ' AND ' )
101- end
102- alias_method :sanitize_sql_hash , :sanitize_sql_hash_for_conditions
103-
10475 # Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause.
10576 # { status: nil, group_id: 1 }
10677 # # => "status = NULL , group_id = 1"
0 commit comments