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

38 lines
843 B
Ruby
Raw Normal View History

module Arel
###
# FIXME hopefully we can remove this
module Crud
# FIXME: this method should go away
def update values
um = UpdateManager.new @engine
2010-08-18 12:52:16 -04:00
if Nodes::SqlLiteral === values
2010-09-20 17:27:34 -04:00
relation = @ctx.froms
2010-08-18 12:52:16 -04:00
else
relation = values.first.first.relation
2010-08-18 12:52:16 -04:00
end
um.table relation
um.set values
2010-11-05 17:09:09 -04:00
um.take @ast.limit
um.order(*@ast.orders)
2010-09-21 12:20:14 -04:00
um.wheres = @ctx.wheres
@engine.connection.update um.to_sql, 'AREL'
end
# FIXME: this method should go away
def insert values
im = InsertManager.new @engine
im.insert values
@engine.connection.insert im.to_sql
end
2010-08-18 14:32:44 -04:00
def delete
dm = DeleteManager.new @engine
dm.wheres = @ctx.wheres
2010-09-20 17:27:34 -04:00
dm.from @ctx.froms
2010-08-23 16:41:34 -04:00
@engine.connection.delete dm.to_sql, 'AREL'
2010-08-18 14:32:44 -04:00
end
end
end