Module: ActiveRecord::QueryMethods

Defined in:
lib/activerecord/monkey_patch/rails4_2.rb

Overview

Original code is the following URL.

https://github.com/rails/rails/blob/v4.2.6/activerecord/lib/active_record/relation/query_methods.rb#L947

Instance Method Summary collapse

Instance Method Details

#build_where(opts, other = []) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/activerecord/monkey_patch/rails4_2.rb', line 13

def build_where(opts, other = [])
  case opts
  when String, Array
    [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]
  when Hash
    opts = ActiveRecord::MonkeyPatch.adjust_timezone_offset(opts)
    opts = PredicateBuilder.resolve_column_aliases(klass, opts)

    tmp_opts, bind_values = create_binds(opts)
    self.bind_values += bind_values

    attributes = @klass.send(:expand_hash_conditions_for_aggregates, tmp_opts)
    add_relations_to_bind_values(attributes)

    PredicateBuilder.build_from_hash(klass, attributes, table)
  else
    [opts]
  end
end