diff options
author | kg8m <takumi.kagiyama@gmail.com> | 2018-02-12 22:56:05 +0900 |
---|---|---|
committer | kg8m <takumi.kagiyama@gmail.com> | 2018-02-27 23:05:54 +0900 |
commit | 2d48268d81644b3b1a558fbdd81941d56dd3d239 (patch) | |
tree | e34f444f2a46ee79626f241e4722073b5220842c /activerecord/test/cases/finder_test.rb | |
parent | f1878fa06efb2eaa2c521022fa79f95b6c49f865 (diff) | |
download | rails-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.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 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], |