diff options
author | Brian Cardarella <bcardarella@gmail.com> | 2011-01-23 11:54:00 -0500 |
---|---|---|
committer | Brian Cardarella <bcardarella@gmail.com> | 2011-01-23 11:54:00 -0500 |
commit | 7b445c6dd578277f7313746fc497429a56e4b43c (patch) | |
tree | c4f41ee671d4f84996f552221bde025774880b60 | |
parent | 5bc709be9eed03022927cbe8ab0708fcfa971f2b (diff) | |
download | rails-7b445c6dd578277f7313746fc497429a56e4b43c.tar.gz rails-7b445c6dd578277f7313746fc497429a56e4b43c.tar.bz2 rails-7b445c6dd578277f7313746fc497429a56e4b43c.zip |
Added MINUS for Oracle
Aliased :minus to :except for the SelectManager
-rw-r--r-- | lib/arel/select_manager.rb | 1 | ||||
-rw-r--r-- | lib/arel/visitors/oracle.rb | 4 | ||||
-rw-r--r-- | test/visitors/test_oracle.rb | 9 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb index 77853ea854..0fa344945e 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -152,6 +152,7 @@ module Arel def except other Nodes::Except.new ast, other.ast end + alias :minus :except def with *subqueries if subqueries.first.is_a? Symbol diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb index aaf0324fd7..3beea287a6 100644 --- a/lib/arel/visitors/oracle.rb +++ b/lib/arel/visitors/oracle.rb @@ -61,6 +61,10 @@ module Arel "raw_rnum_ > #{visit o.expr}" end + def visit_Arel_Nodes_Except o + "( #{visit o.left} MINUS #{visit o.right} )" + end + ### # Hacks for the order clauses specific to Oracle def order_hacks o diff --git a/test/visitors/test_oracle.rb b/test/visitors/test_oracle.rb index c6fcb7134c..87b94409e3 100644 --- a/test/visitors/test_oracle.rb +++ b/test/visitors/test_oracle.rb @@ -134,6 +134,15 @@ module Arel end end + + it 'modified except to be minus' do + left = Nodes::SqlLiteral.new("SELECT * FROM users WHERE age > 10") + right = Nodes::SqlLiteral.new("SELECT * FROM users WHERE age > 20") + sql = @visitor.accept Nodes::Except.new(left, right) + sql.must_be_like %{ + ( SELECT * FROM users WHERE age > 10 MINUS SELECT * FROM users WHERE age > 20 ) + } + end end end end |