diff options
author | Lucia Escanellas <raviolicode@gmail.com> | 2011-06-23 22:32:22 -0300 |
---|---|---|
committer | Lucia Escanellas <raviolicode@gmail.com> | 2011-06-24 13:37:08 -0300 |
commit | 9734a416faaa8149fa5914b0afe2e6761ad5ec20 (patch) | |
tree | 1f4873033932715031f163b42b5ebd49b347d23d /activerecord/test/cases | |
parent | 8a1319dec09672cbb1a4d6fce1db09f10c44bceb (diff) | |
download | rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.tar.gz rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.tar.bz2 rails-9734a416faaa8149fa5914b0afe2e6761ad5ec20.zip |
Improve ordering of multiple columns on postgresql
* Only on postgresql, order("first asc, second asc") was invalid
* Closes #1720
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index aa94c9b87e..d88bde3860 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -176,6 +176,13 @@ class RelationTest < ActiveRecord::TestCase assert_equal entrants(:first).name, entrants.first.name end + def test_finding_with_cross_table_order_and_limit + tags = Tag.includes(:taggings) \ + .order("tags.name asc, taggings.taggable_id asc, REPLACE('abc', taggings.taggable_type, taggings.taggable_type)") \ + .limit(1).to_a + assert_equal 1, tags.length + end + def test_finding_with_complex_order_and_limit tags = Tag.includes(:taggings).order("REPLACE('abc', taggings.taggable_type, taggings.taggable_type)").limit(1).to_a assert_equal 1, tags.length |