aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-21 15:46:24 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-21 15:46:24 -0500
commit0b9af9762a5f3431f83a9bba6919fef9346e310a (patch)
tree7731a00a00ff0588835fe2e7f7164be0a4264116 /test
parentcae83ce964b9919b890bb7fa6f920a536e6b5425 (diff)
downloadrails-0b9af9762a5f3431f83a9bba6919fef9346e310a.tar.gz
rails-0b9af9762a5f3431f83a9bba6919fef9346e310a.tar.bz2
rails-0b9af9762a5f3431f83a9bba6919fef9346e310a.zip
adding Distinct ON node
Diffstat (limited to 'test')
-rw-r--r--test/test_select_manager.rb2
-rw-r--r--test/visitors/test_oracle.rb4
-rw-r--r--test/visitors/test_postgres.rb11
3 files changed, 14 insertions, 3 deletions
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