diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-19 19:39:55 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-19 19:39:55 -0600 |
commit | 09f057d1933d341b04833815f903b63a904f0328 (patch) | |
tree | be8c9bc6ba4fed745bd9c7c7bf3b0579fcc97f94 /activerecord/lib/active_record/relation | |
parent | d57d5595c0cb1e9859cac77fd9507320b67aadda (diff) | |
parent | b27fb2d8e76a31eb0d12b0bcea1fbd12dcf35320 (diff) | |
download | rails-09f057d1933d341b04833815f903b63a904f0328.tar.gz rails-09f057d1933d341b04833815f903b63a904f0328.tar.bz2 rails-09f057d1933d341b04833815f903b63a904f0328.zip |
Merge pull request #21987 from yui-knk/refactor_where
Green version of moving the handling of supported arguments to `where`
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/where_clause_factory.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 0dcecbd42d..55fd0e0b52 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -552,8 +552,6 @@ module ActiveRecord WhereChain.new(spawn) elsif opts.blank? self - elsif !opts.is_a?(String) && !opts.respond_to?(:to_h) - raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" else spawn.where!(opts, *rest) end diff --git a/activerecord/lib/active_record/relation/where_clause_factory.rb b/activerecord/lib/active_record/relation/where_clause_factory.rb index 83ac074f97..a81ff98e49 100644 --- a/activerecord/lib/active_record/relation/where_clause_factory.rb +++ b/activerecord/lib/active_record/relation/where_clause_factory.rb @@ -20,8 +20,10 @@ module ActiveRecord attributes, binds = predicate_builder.create_binds(attributes) parts = predicate_builder.build_from_hash(attributes) - else + when Arel::Nodes::Node parts = [opts] + else + raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" end WhereClause.new(parts, binds) |