def sanitize_sql_hash_for_conditions(attrs, table_name = quoted_table_name)
attrs = expand_hash_conditions_for_aggregates(attrs)
conditions = attrs.map do |attr, value|
unless value.is_a?(Hash)
attr = attr.to_s
if attr.include?('.')
table_name, attr = attr.split('.', 2)
table_name = connection.quote_table_name(table_name)
end
"#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
else
sanitize_sql_hash_for_conditions(value, connection.quote_table_name(attr.to_s))
end
end.join(' AND ')
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
end