From 2d48268d81644b3b1a558fbdd81941d56dd3d239 Mon Sep 17 00:00:00 2001 From: kg8m Date: Mon, 12 Feb 2018 22:56:05 +0900 Subject: 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. --- activerecord/test/cases/finder_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/cases/finder_test.rb') 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], -- cgit v1.2.3