sanitize_sql_hash_for_conditions

sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name) Instance Protected methods 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" { other_records: {

sanitize_sql_hash_for_assignment

sanitize_sql_hash_for_assignment(attrs, table) Instance Protected methods Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause. { status: nil, group_id: 1 } # => "status = NULL , group_id = 1"

sanitize_sql_hash

sanitize_sql_hash(attrs, default_table_name = self.table_name) Instance Protected methods Alias for: sanitize_sql_hash_for_conditions

sanitize_sql_for_conditions

sanitize_sql_for_conditions(condition, table_name = self.table_name) Instance Protected methods Accepts an array, hash, or string of SQL conditions and sanitizes them into a valid SQL fragment for a WHERE clause. ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" { name: "foo'bar", group_id: 4 } returns "name='foo''bar' and group_id='4'" "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'" sanitize_sql

sanitize_sql_for_assignment

sanitize_sql_for_assignment(assignments, default_table_name = self.table_name) Instance Protected methods Accepts an array, hash, or string of SQL conditions and sanitizes them into a valid SQL fragment for a SET clause. { name: nil, group_id: 4 } returns "name = NULL , group_id='4'"

sanitize_sql_array

sanitize_sql_array(ary) Instance Protected methods Accepts an array of conditions. The array has each value sanitized and interpolated into the SQL statement. ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"

sanitize_sql

sanitize_sql(condition, table_name = self.table_name) Instance Protected methods Also aliased as: sanitize_conditions

sanitize_conditions

sanitize_conditions(condition, table_name = self.table_name) Instance Protected methods Alias for: sanitize_sql

expand_hash_conditions_for_aggregates

expand_hash_conditions_for_aggregates(attrs) Instance Protected methods Accepts a hash of SQL conditions and replaces those attributes that correspond to a composed_of relationship with their expanded aggregate attribute values. Given: class Person < ActiveRecord::Base composed_of :address, class_name: "Address", mapping: [%w(address_street street), %w(address_city city)] end Then: { address: Address.new("813 abc st.", "chicago") } # => { address_street: "813 abc st.

to_hash

to_hash() Instance Public methods