aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-01-04 12:19:41 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-01-04 12:27:44 +0900
commitb334aa0ea4008221c475adc5b124f3b23b785aba (patch)
treeb4706f4b15126779070627a4494f808eafe36d2e /activerecord/lib/active_record/core.rb
parent127509c071b4f983f2beafc8766e990670a21215 (diff)
downloadrails-b334aa0ea4008221c475adc5b124f3b23b785aba.tar.gz
rails-b334aa0ea4008221c475adc5b124f3b23b785aba.tar.bz2
rails-b334aa0ea4008221c475adc5b124f3b23b785aba.zip
Fix `find_by` and `where` consistency
The alternative of #26213. Currently `find_by` and `where` with AR object return inconsistent result. This is caused by statement cache does not support AR object. Passing to finder method to fix the issue. Fixes #26210.
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 5d0f82130d..6d2361c4ac 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -196,12 +196,12 @@ module ActiveRecord
end
def find_by(*args) # :nodoc:
- return super if scope_attributes? || !(Hash === args.first) || reflect_on_all_aggregations.any?
+ return super if scope_attributes? || reflect_on_all_aggregations.any?
hash = args.first
- return super if hash.values.any? { |v|
- v.nil? || Array === v || Hash === v || Relation === v
+ return super if !(Hash === hash) || hash.values.any? { |v|
+ v.nil? || Array === v || Hash === v || Relation === v || Base === v
}
# We can't cache Post.find_by(author: david) ...yet