#where fails if opts.responds_to?(:==) unexpectedly

Sometimes opts passed in might respond to ==, e.g. `Arel::Nodes::Grouping`. In this case, `opts == :chain` returns `Arel::Nodes::Equality` which causes odd behaviour. Prefer `if :chain == opts` which guarantees that `Symbol#==` would be invoked. Alternatively consider `eql?`.
This commit is contained in:
Samuel Williams 2015-09-05 11:33:21 +12:00
parent 21ffef38a5
commit c431f1754b

@ -548,7 +548,7 @@ def joins!(*args) # :nodoc:
# If the condition is any blank-ish object, then #where is a no-op and returns # If the condition is any blank-ish object, then #where is a no-op and returns
# the current relation. # the current relation.
def where(opts = :chain, *rest) def where(opts = :chain, *rest)
if opts == :chain if :chain == opts
WhereChain.new(spawn) WhereChain.new(spawn)
elsif opts.blank? elsif opts.blank?
self self