method
sanitize_sql_hash_for_conditions
v2.1.0 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Base
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (11)
- 2.2.1 (5)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
sanitize_sql_hash_for_conditions(attrs)
protected
Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
{ :name => "foo'bar", :group_id => 4 } # => "name='foo''bar' and group_id= 4" { :status => nil, :group_id => [1,2,3] } # => "status IS NULL and group_id IN (1,2,3)" { :age => 13..18 } # => "age BETWEEN 13 AND 18" { 'other_records.id' => 7 } # => "`other_records`.`id` = 7"
And for value objects on a composed_of relationship:
{ :address => Address.new("123 abc st.", "chicago") } # => "address_street='123 abc st.' and address_city='chicago'"