1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added MINUS for Oracle

Aliased :minus to :except for the SelectManager
This commit is contained in:
Brian Cardarella 2011-01-23 11:54:00 -05:00
parent 5bc709be9e
commit 7b445c6dd5
3 changed files with 14 additions and 0 deletions

View file

@ -152,6 +152,7 @@ module Arel
def except other def except other
Nodes::Except.new ast, other.ast Nodes::Except.new ast, other.ast
end end
alias :minus :except
def with *subqueries def with *subqueries
if subqueries.first.is_a? Symbol if subqueries.first.is_a? Symbol

View file

@ -61,6 +61,10 @@ module Arel
"raw_rnum_ > #{visit o.expr}" "raw_rnum_ > #{visit o.expr}"
end end
def visit_Arel_Nodes_Except o
"( #{visit o.left} MINUS #{visit o.right} )"
end
### ###
# Hacks for the order clauses specific to Oracle # Hacks for the order clauses specific to Oracle
def order_hacks o def order_hacks o

View file

@ -134,6 +134,15 @@ module Arel
end end
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 end
end end