aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorkg8m <takumi.kagiyama@gmail.com>2018-02-12 22:56:05 +0900
committerkg8m <takumi.kagiyama@gmail.com>2018-02-27 23:05:54 +0900
commit2d48268d81644b3b1a558fbdd81941d56dd3d239 (patch)
treee34f444f2a46ee79626f241e4722073b5220842c /activerecord/test/cases/finder_test.rb
parentf1878fa06efb2eaa2c521022fa79f95b6c49f865 (diff)
downloadrails-2d48268d81644b3b1a558fbdd81941d56dd3d239.tar.gz
rails-2d48268d81644b3b1a558fbdd81941d56dd3d239.tar.bz2
rails-2d48268d81644b3b1a558fbdd81941d56dd3d239.zip
Fix `#columsn_for_distinct` of MySQL and PostgreSQL
Prevent `ActiveRecord::FinderMethods#limited_ids_for` from using correct primary key values even if `ORDER BY` columns include other table's primary key. Fixes #28364.
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-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 ebddf81449..d85910d9c6 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -1189,6 +1189,11 @@ class FinderTest < ActiveRecord::TestCase
order("author_addresses_authors.id DESC").limit(3).to_a.size
end
+ def test_find_with_eager_loading_collection_and_ordering_by_collection_primary_key
+ assert_equal Post.first, Post.eager_load(comments: :ratings).
+ order("posts.id, ratings.id, comments.id").first
+ end
+
def test_find_with_nil_inside_set_passed_for_one_attribute
client_of = Company.
where(client_of: [2, 1, nil],