aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-06-13 01:04:33 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-06-13 01:13:54 +0900
commit681a0a0299500024635e790c1ceb2da281652444 (patch)
treeffcd0257d826c89ed1d07bd18f25fc556a142407 /activerecord/test/cases/associations/eager_test.rb
parent8a39123d5dd11dcc63e8f1a915cf66fa0e2cf9a3 (diff)
downloadrails-681a0a0299500024635e790c1ceb2da281652444.tar.gz
rails-681a0a0299500024635e790c1ceb2da281652444.tar.bz2
rails-681a0a0299500024635e790c1ceb2da281652444.zip
Fix `calculate` with a string value in `from` and eager loading
`construct_relation_for_association_calculations` pass a string value to `construct_join_dependency` when setting a string value in `from`. It should not pass a string value, but always `joins_values`. Related #14834, #19452. Fixes #24193.
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index f7bb3e54d5..80d9a6083b 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -90,6 +90,10 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_no_queries { authors.map(&:post) }
end
+ def test_calculate_with_string_in_from_and_eager_loading
+ assert_equal 10, Post.from("authors, posts").eager_load(:comments).where("posts.author_id = authors.id").count
+ end
+
def test_with_two_tables_in_from_without_getting_double_quoted
posts = Post.select("posts.*").from("authors, posts").eager_load(:comments).where("posts.author_id = authors.id").order("posts.id").to_a
assert_equal 2, posts.first.comments.size