2010-08-16 17:56:56 -04:00
|
|
|
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
|
|
|
|
2010-08-23 16:28:08 -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
|
2010-09-14 16:39:33 -04:00
|
|
|
relation = values.first.first.relation
|
2010-08-18 12:52:16 -04:00
|
|
|
end
|
2010-09-14 16:39:33 -04:00
|
|
|
um.table relation
|
2010-08-16 17:56:56 -04:00
|
|
|
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
|
2010-09-14 16:39:33 -04:00
|
|
|
|
2010-08-23 16:28:08 -04:00
|
|
|
@engine.connection.update um.to_sql, 'AREL'
|
2010-08-16 17:56:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# FIXME: this method should go away
|
|
|
|
def insert values
|
|
|
|
im = InsertManager.new @engine
|
|
|
|
im.insert values
|
2010-08-23 16:28:08 -04:00
|
|
|
@engine.connection.insert im.to_sql
|
2010-08-16 17:56:56 -04:00
|
|
|
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
|
2010-08-16 17:56:56 -04:00
|
|
|
end
|
|
|
|
end
|