1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/crud.rb
2018-02-24 18:11:47 +10:30

42 lines
829 B
Ruby

# frozen_string_literal: true
module Arel # :nodoc: all
###
# FIXME hopefully we can remove this
module Crud
def compile_update(values, pk)
um = UpdateManager.new
if Nodes::SqlLiteral === values
relation = @ctx.from
else
relation = values.first.first.relation
end
um.key = pk
um.table relation
um.set values
um.take @ast.limit.expr if @ast.limit
um.order(*@ast.orders)
um.wheres = @ctx.wheres
um
end
def compile_insert(values)
im = create_insert
im.insert values
im
end
def create_insert
InsertManager.new
end
def compile_delete
dm = DeleteManager.new
dm.take @ast.limit.expr if @ast.limit
dm.wheres = @ctx.wheres
dm.from @ctx.froms
dm
end
end
end