diff options
author | Hendy Tanata <htanata@gmail.com> | 2017-03-28 18:53:58 -0700 |
---|---|---|
committer | Hendy Tanata <htanata@gmail.com> | 2017-03-28 19:40:52 -0700 |
commit | 3d6176fded424a2195e399d031e343bbcd0edcad (patch) | |
tree | 1bf64758cf0ed3cc0387aa2cef163ededa12fd8e /activerecord/test | |
parent | 29d6e9cdc4d8528b6676843509347fc8fead935b (diff) | |
download | rails-3d6176fded424a2195e399d031e343bbcd0edcad.tar.gz rails-3d6176fded424a2195e399d031e343bbcd0edcad.tar.bz2 rails-3d6176fded424a2195e399d031e343bbcd0edcad.zip |
Load only needed records on ActiveRecord::Relation#inspect
Instead of loading all records and returning only a subset of those,
just load the records as needed.
Fixes #25537.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 8c06b1537a..856469c710 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1901,6 +1901,12 @@ class RelationTest < ActiveRecord::TestCase assert_equal "#<ActiveRecord::Relation [#{Post.limit(10).map(&:inspect).join(', ')}, ...]>", relation.inspect end + test "relations don't load all records in #inspect" do + assert_sql(/LIMIT/) do + Post.all.inspect + end + end + test "already-loaded relations don't perform a new query in #inspect" do relation = Post.limit(2) relation.to_a |