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:
parent
5bc709be9e
commit
7b445c6dd5
3 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue