aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-08-23 23:36:40 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-08-23 23:36:40 -0700
commit5b27d15ff87b4a057edae942f8173f5ceb4a9196 (patch)
treea31fdefdf8b02c81eb29cc82ccaf198084ed3d6d /activerecord/test
parent33c05363e2ed52aa8bdbf5ebf9ee5226ab85ecbc (diff)
parent291fece47a954eb986816a89164bda599d54db46 (diff)
downloadrails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.tar.gz
rails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.tar.bz2
rails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.zip
Merge pull request #16649 from Agis-/pg-columns-for-distinct
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
index cfff1f980b..01b3f350b5 100644
--- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
@@ -334,6 +334,14 @@ module ActiveRecord
@connection.columns_for_distinct("posts.id", ["posts.created_at desc", "posts.position asc"])
end
+ def test_columns_for_distinct_with_case
+ assert_equal(
+ 'posts.id, CASE WHEN author.is_active THEN UPPER(author.name) ELSE UPPER(author.email) END AS alias_0',
+ @connection.columns_for_distinct('posts.id',
+ ["CASE WHEN author.is_active THEN UPPER(author.name) ELSE UPPER(author.email) END"])
+ )
+ end
+
def test_columns_for_distinct_blank_not_nil_orders
assert_equal "posts.id, posts.created_at AS alias_0",
@connection.columns_for_distinct("posts.id", ["posts.created_at desc", "", " "])