method
build_where
v4.1.8 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
build_where(opts, other = [])private
No documentation available.
# File activerecord/lib/active_record/relation/query_methods.rb, line 938
def build_where(opts, other = [])
case opts
when String, Array
#TODO: Remove duplication with: /activerecord/lib/active_record/sanitization.rb:113
values = Hash === other.first ? other.first.values : other
values.grep(ActiveRecord::Relation) do |rel|
self.bind_values += rel.bind_values
end
[@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]
when Hash
opts = PredicateBuilder.resolve_column_aliases(klass, opts)
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
add_relations_to_bind_values(attributes)
PredicateBuilder.build_from_hash(klass, attributes, table)
else
[opts]
end
end