diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-07-21 07:49:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-21 07:49:34 -0500 |
commit | d162188dd662a7d9f62ba8431474f50bc35e3e93 (patch) | |
tree | b47237a957f6021193fe7299b83bd27544e22165 /activerecord/test/cases | |
parent | 3576782888c307e3e192c44e332b957cd1174128 (diff) | |
parent | 06d506f0d001ef09120212e4a15cd3e6437ff876 (diff) | |
download | rails-d162188dd662a7d9f62ba8431474f50bc35e3e93.tar.gz rails-d162188dd662a7d9f62ba8431474f50bc35e3e93.tar.bz2 rails-d162188dd662a7d9f62ba8431474f50bc35e3e93.zip |
Merge pull request #24131 from brchristian/limit_and_primary_key
ActiveRecord: limit() and primary_key
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 39ffe12ec6..2f256dd36a 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -1265,6 +1265,21 @@ class FinderTest < ActiveRecord::TestCase end end + def test_first_and_last_with_limit_for_order_without_primary_key + # While Topic.first should impose an ordering by primary key, + # Topic.limit(n).first should not + + Topic.first.touch # PostgreSQL changes the default order if no order clause is used + + assert_equal Topic.limit(1).to_a.first, Topic.limit(1).first + assert_equal Topic.limit(2).to_a.first, Topic.limit(2).first + assert_equal Topic.limit(2).to_a.first(2), Topic.limit(2).first(2) + + assert_equal Topic.limit(1).to_a.last, Topic.limit(1).last + assert_equal Topic.limit(2).to_a.last, Topic.limit(2).last + assert_equal Topic.limit(2).to_a.last(2), Topic.limit(2).last(2) + end + def test_finder_with_offset_string assert_nothing_raised { Topic.offset("3").to_a } end |