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-08-18 12:52:16 -04:00
|
|
|
um.table @ctx.froms.last
|
|
|
|
else
|
|
|
|
um.table values.first.first.relation
|
|
|
|
end
|
2010-08-16 17:56:56 -04:00
|
|
|
um.set values
|
|
|
|
um.wheres = @ctx.wheres
|
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
|
|
|
|
dm.from @ctx.froms.last
|
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
|