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

69 lines
1.5 KiB
Ruby
Raw Normal View History

module Arel
###
# FIXME hopefully we can remove this
module Crud
def compile_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
um
end
# FIXME: this method should go away
def update values
if $VERBOSE
warn <<-eowarn
update (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
switch to `compile_update`
eowarn
end
um = compile_update values
@engine.connection.update um.to_sql, 'AREL'
end
2010-12-02 17:01:08 -05:00
def compile_insert values
im = InsertManager.new @engine
im.insert values
2010-12-02 17:01:08 -05:00
im
end
# FIXME: this method should go away
def insert values
if $VERBOSE
warn <<-eowarn
insert (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
2010-12-02 17:01:08 -05:00
switch to `compile_insert`
eowarn
end
@engine.connection.insert compile_insert(values).to_sql
end
2010-08-18 14:32:44 -04:00
def compile_delete
2010-08-18 14:32:44 -04:00
dm = DeleteManager.new @engine
dm.wheres = @ctx.wheres
2010-09-20 17:27:34 -04:00
dm.from @ctx.froms
dm
end
def delete
if $VERBOSE
warn <<-eowarn
delete (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
switch to `compile_delete`
eowarn
end
@engine.connection.delete compile_delete.to_sql, 'AREL'
2010-08-18 14:32:44 -04:00
end
end
end