aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations/eager_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-12 05:14:55 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-12 05:14:55 +0000
commitef4ac31de3f310c6426a6d9ebc86b4810ac6325b (patch)
tree6bc6dc2072ad82162968ce699ba80d0cbf2fc4ae /activerecord/test/associations/eager_test.rb
parent3b6555acd4516167f5ca094eeae50bf5ffc59db9 (diff)
downloadrails-ef4ac31de3f310c6426a6d9ebc86b4810ac6325b.tar.gz
rails-ef4ac31de3f310c6426a6d9ebc86b4810ac6325b.tar.bz2
rails-ef4ac31de3f310c6426a6d9ebc86b4810ac6325b.zip
PostgreSQL: use a subselect to correctly perform eager finds with :limit and :order. Closes #4668.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5887 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations/eager_test.rb')
-rw-r--r--activerecord/test/associations/eager_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/associations/eager_test.rb b/activerecord/test/associations/eager_test.rb
index b303363f00..0d69af1c10 100644
--- a/activerecord/test/associations/eager_test.rb
+++ b/activerecord/test/associations/eager_test.rb
@@ -290,6 +290,16 @@ class EagerAssociationTest < Test::Unit::TestCase
def find_all_ordered(className, include=nil)
className.find(:all, :order=>"#{className.table_name}.#{className.primary_key}", :include=>include)
end
+
+ def test_limited_eager_with_order
+ assert_equal [posts(:thinking), posts(:sti_comments)], Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title)', :limit => 2, :offset => 1)
+ assert_equal [posts(:sti_post_and_comments), posts(:sti_comments)], Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC', :limit => 2, :offset => 1)
+ end
+
+ def test_limited_eager_with_multiple_order_columns
+ assert_equal [posts(:thinking), posts(:sti_comments)], Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title), posts.id', :limit => 2, :offset => 1)
+ assert_equal [posts(:sti_post_and_comments), posts(:sti_comments)], Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC, posts.id', :limit => 2, :offset => 1)
+ end
def test_eager_with_multiple_associations_with_same_table_has_many_and_habtm
# Eager includes of has many and habtm associations aren't necessarily sorted in the same way