aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2015-09-05 11:33:21 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2015-09-05 11:33:21 +1200
commitc431f1754b4329b972ce2e715df0e33aeaee7d30 (patch)
treea37ebccece492962a5da85cea06f55c4fabbbf78
parent21ffef38a5dc5a6a21f7e841aecab5b51f4fd185 (diff)
downloadrails-c431f1754b4329b972ce2e715df0e33aeaee7d30.tar.gz
rails-c431f1754b4329b972ce2e715df0e33aeaee7d30.tar.bz2
rails-c431f1754b4329b972ce2e715df0e33aeaee7d30.zip
#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?`.
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 706c99c245..e25b889851 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -548,7 +548,7 @@ module ActiveRecord
# If the condition is any blank-ish object, then #where is a no-op and returns
# the current relation.
def where(opts = :chain, *rest)
- if opts == :chain
+ if :chain == opts
WhereChain.new(spawn)
elsif opts.blank?
self