diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-20 17:53:49 +0900 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-20 17:53:49 +0900 |
commit | 90f99689121487328f022fd09841b62378423afe (patch) | |
tree | 68ac303c4c4ce352eff16f30727b59a6d6bfece0 /activerecord/test/cases | |
parent | 793e4aa9b63a066d0bf0dbd291969ec9cd2fc204 (diff) | |
download | rails-90f99689121487328f022fd09841b62378423afe.tar.gz rails-90f99689121487328f022fd09841b62378423afe.tar.bz2 rails-90f99689121487328f022fd09841b62378423afe.zip |
Fix find_by with associations not working with adequate record
For now, we will just skip the cache when a non-column key is used in the hash.
If the future, we can probably move some of the logic in PredicateBuilder.expand
up the chain to make caching possible for association queries.
Closes #16903
Fixes #16884
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 7228a75548..ac570ecbe0 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -1073,6 +1073,11 @@ class FinderTest < ActiveRecord::TestCase assert_equal nil, Post.find_by("1 = 0") end + test "find_by with associations" do + assert_equal authors(:david), Post.find_by(author: authors(:david)).author + assert_equal authors(:mary) , Post.find_by(author: authors(:mary) ).author + end + test "find_by doesn't have implicit ordering" do assert_sql(/^((?!ORDER).)*$/) { Post.find_by(id: posts(:eager_other).id) } end |