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

43 lines
829 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-02-24 01:45:50 -05:00
2018-02-24 02:41:47 -05:00
module Arel # :nodoc: all
###
# FIXME hopefully we can remove this
module Crud
2018-02-24 01:45:50 -05:00
def compile_update(values, pk)
um = UpdateManager.new
2010-08-18 12:52:16 -04:00
if Nodes::SqlLiteral === values
relation = @ctx.from
2010-08-18 12:52:16 -04:00
else
relation = values.first.first.relation
2010-08-18 12:52:16 -04:00
end
um.key = pk
um.table relation
um.set values
um.take @ast.limit.expr if @ast.limit
2010-11-05 17:09:09 -04:00
um.order(*@ast.orders)
2010-09-21 12:20:14 -04:00
um.wheres = @ctx.wheres
um
end
2018-02-24 01:45:50 -05:00
def compile_insert(values)
2011-03-22 00:23:48 -04:00
im = create_insert
im.insert values
2010-12-02 17:01:08 -05:00
im
end
2011-03-22 00:23:48 -04:00
def create_insert
InsertManager.new
2011-03-22 00:23:48 -04:00
end
def compile_delete
dm = DeleteManager.new
dm.take @ast.limit.expr if @ast.limit
2010-08-18 14:32:44 -04:00
dm.wheres = @ctx.wheres
2010-09-20 17:27:34 -04:00
dm.from @ctx.froms
dm
end
end
end