method

sanitize_sql_hash_for_conditions

Importance_1
v2.0.3 - Show latest stable - 0 notes - Class: ActiveRecord::Base
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"
Show source
Register or log in to add new notes.