aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
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/test
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/test')
-rw-r--r--activerecord/test/cases/finder_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 97010b1fd9..e0ad9f5ec1 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -339,6 +339,11 @@ class FinderTest < ActiveRecord::TestCase
assert_equal author.post, Post.find_by(author_id: Author.where(id: author))
end
+ def test_find_by_and_where_consistency_with_active_record_instance
+ author = authors(:david)
+ assert_equal Post.where(author_id: author).take, Post.find_by(author_id: author)
+ end
+
def test_take
assert_equal topics(:first), Topic.take
end