From f137c2b838773be3cfa916e9f7a91773b9245bda Mon Sep 17 00:00:00 2001 From: kennyj Date: Thu, 2 Aug 2012 02:34:38 +0900 Subject: Backport #5168 to 3-2-stable. Fix a problem that NULLS is ignored by postgresql_adapter.rb while creating distincts. --- .../test/cases/adapters/postgresql/postgresql_adapter_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/cases/adapters') diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index d57794daf8..3eb73d3093 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -179,6 +179,11 @@ module ActiveRecord assert_equal Arel.sql('$2'), bind end + def test_distinct_with_nulls + assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls first"]) + assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls last"]) + end + private def insert(ctx, data) binds = data.map { |name, value| -- cgit v1.2.3