mirror of https://github.com/rails/rails
Move `where` from `TreeManager` to `SelectManager`
`TreeManager` is inherited by `InsertManager` but `where` on `InsertManager` doesn't work. And also, remove `@ctx` since the instance variable is used only for the `SelectManager`.
This commit is contained in:
parent
92281b4911
commit
096719ce2a
|
@ -5,9 +5,7 @@ module Arel # :nodoc: all
|
|||
include TreeManager::StatementMethods
|
||||
|
||||
def initialize(table = nil)
|
||||
super()
|
||||
@ast = Nodes::DeleteStatement.new(table)
|
||||
@ctx = @ast
|
||||
end
|
||||
|
||||
def from(relation)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
module Arel # :nodoc: all
|
||||
class InsertManager < Arel::TreeManager
|
||||
def initialize(table = nil)
|
||||
super()
|
||||
@ast = Nodes::InsertStatement.new(table)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ module Arel # :nodoc: all
|
|||
STRING_OR_SYMBOL_CLASS = [Symbol, String]
|
||||
|
||||
def initialize(table = nil)
|
||||
super()
|
||||
@ast = Nodes::SelectStatement.new(table)
|
||||
@ctx = @ast.cores.last
|
||||
end
|
||||
|
@ -182,6 +181,14 @@ module Arel # :nodoc: all
|
|||
@ast.orders
|
||||
end
|
||||
|
||||
def where(expr)
|
||||
if Arel::TreeManager === expr
|
||||
expr = expr.ast
|
||||
end
|
||||
@ctx.wheres << expr
|
||||
self
|
||||
end
|
||||
|
||||
def where_sql(engine = Table.engine)
|
||||
return if @ctx.wheres.empty?
|
||||
|
||||
|
|
|
@ -40,10 +40,6 @@ module Arel # :nodoc: all
|
|||
|
||||
attr_reader :ast
|
||||
|
||||
def initialize
|
||||
@ctx = nil
|
||||
end
|
||||
|
||||
def to_dot
|
||||
collector = Arel::Collectors::PlainString.new
|
||||
collector = Visitors::Dot.new.accept @ast, collector
|
||||
|
@ -60,13 +56,5 @@ module Arel # :nodoc: all
|
|||
super
|
||||
@ast = @ast.clone
|
||||
end
|
||||
|
||||
def where(expr)
|
||||
if Arel::TreeManager === expr
|
||||
expr = expr.ast
|
||||
end
|
||||
@ctx.wheres << expr
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,7 @@ module Arel # :nodoc: all
|
|||
include TreeManager::StatementMethods
|
||||
|
||||
def initialize(table = nil)
|
||||
super()
|
||||
@ast = Nodes::UpdateStatement.new(table)
|
||||
@ctx = @ast
|
||||
end
|
||||
|
||||
###
|
||||
|
|
Loading…
Reference in New Issue