aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2015-10-18 10:51:03 +0900
committeryui-knk <spiketeika@gmail.com>2015-10-18 10:51:03 +0900
commitb27fb2d8e76a31eb0d12b0bcea1fbd12dcf35320 (patch)
tree0ab4da5e348c8b127229c1dd3a95435c874507e1 /activerecord/lib
parent6c36c369be0cdd8f5f5b47f77ba79d492db98f32 (diff)
downloadrails-b27fb2d8e76a31eb0d12b0bcea1fbd12dcf35320.tar.gz
rails-b27fb2d8e76a31eb0d12b0bcea1fbd12dcf35320.tar.bz2
rails-b27fb2d8e76a31eb0d12b0bcea1fbd12dcf35320.zip
Green version of moving the handling of supported arguments to `where`
This commit follow up of 4d8f62d. The difference from 4d8f62d are below: * Change `WhereClauseFactory` to accept `Arel::Nodes::Node` * Change test cases of `relation_test.rb`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb2
-rw-r--r--activerecord/lib/active_record/relation/where_clause_factory.rb4
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)