aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/comment.rb
diff options
context:
space:
mode:
authorSammy Larbi <sam@codeodor.com>2014-08-31 14:18:02 -0500
committerSammy Larbi <sam@codeodor.com>2014-09-04 10:05:01 -0500
commit4abbdbdf1656e9bed6f744723a901cbaf6878df4 (patch)
treee4cee59666ea912a081f80722d7218621b7ed8b9 /activerecord/test/models/comment.rb
parent40f9407b872add660db45e59316a5a195f16d563 (diff)
downloadrails-4abbdbdf1656e9bed6f744723a901cbaf6878df4.tar.gz
rails-4abbdbdf1656e9bed6f744723a901cbaf6878df4.tar.bz2
rails-4abbdbdf1656e9bed6f744723a901cbaf6878df4.zip
Skip StatementCache for eager loaded associations (Fixes #16761)
Eagerly loaded collection and singular associations are ignored by the StatementCache, which causes errors when the queries they generate reference columns that were not eagerly loaded. This commit skips the creation of the StatementCache as a fix for these scenarios.
Diffstat (limited to 'activerecord/test/models/comment.rb')
-rw-r--r--activerecord/test/models/comment.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index 7a88299d08..b38b17e90e 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -52,3 +52,8 @@ class CommentThatAutomaticallyAltersPostBody < Comment
comment.post.update_attributes(body: "Automatically altered")
end
end
+
+class CommentWithDefaultScopeReferencesAssociation < Comment
+ default_scope ->{ includes(:developer).order('developers.name').references(:developer) }
+ belongs_to :developer
+end