From 0b9af9762a5f3431f83a9bba6919fef9346e310a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 21 Apr 2011 15:46:24 -0500 Subject: adding Distinct ON node --- test/test_select_manager.rb | 2 +- test/visitors/test_oracle.rb | 4 ++-- test/visitors/test_postgres.rb | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index 351d8d321b..8de1520b6f 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -54,7 +54,7 @@ module Arel def test_join_sources manager = Arel::SelectManager.new Table.engine manager.join_sources << Arel::Nodes::StringJoin.new('foo') - assert_equal "SELECT FROM 'foo'", manager.to_sql + assert_equal "SELECT FROM 'foo'", manager.to_sql end describe 'backwards compatibility' do diff --git a/test/visitors/test_oracle.rb b/test/visitors/test_oracle.rb index 87b94409e3..eaf68013a7 100644 --- a/test/visitors/test_oracle.rb +++ b/test/visitors/test_oracle.rb @@ -101,7 +101,7 @@ module Arel sql.must_be_like %{ SELECT * FROM ( SELECT raw_sql_.*, rownum raw_rnum_ - FROM (SELECT ) raw_sql_ + FROM (SELECT) raw_sql_ WHERE rownum <= 20 ) WHERE raw_rnum_ > 10 @@ -126,7 +126,7 @@ module Arel sql.must_be_like %{ SELECT * FROM ( SELECT raw_sql_.*, rownum raw_rnum_ - FROM (SELECT ) raw_sql_ + FROM (SELECT) raw_sql_ ) WHERE raw_rnum_ > 10 } diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb index 74446c23ba..446eae0c4a 100644 --- a/test/visitors/test_postgres.rb +++ b/test/visitors/test_postgres.rb @@ -32,6 +32,17 @@ module Arel assert_equal 1, sql.scan(/LIMIT/).length, 'should have one limit' end + it 'should support DISTINCT ON' do + core = Arel::Nodes::SelectCore.new + core.set_quantifier = Arel::Nodes::DistinctOn.new(Arel.sql('aaron')) + assert_match 'DISTINCT ON ( aaron )', @visitor.accept(core) + end + + it 'should support DISTINCT' do + core = Arel::Nodes::SelectCore.new + core.set_quantifier = Arel::Nodes::Distinct.new + assert_equal 'SELECT DISTINCT', @visitor.accept(core) + end end end end -- cgit v1.2.3