aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/crud.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/crud.rb')
-rw-r--r--lib/arel/crud.rb45
1 files changed, 38 insertions, 7 deletions
diff --git a/lib/arel/crud.rb b/lib/arel/crud.rb
index b3199e6d38..ec58734456 100644
--- a/lib/arel/crud.rb
+++ b/lib/arel/crud.rb
@@ -2,8 +2,7 @@ module Arel
###
# FIXME hopefully we can remove this
module Crud
- # FIXME: this method should go away
- def update values
+ def compile_update values
um = UpdateManager.new @engine
if Nodes::SqlLiteral === values
@@ -16,22 +15,54 @@ module Arel
um.take @ast.limit
um.order(*@ast.orders)
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
- # FIXME: this method should go away
- def insert values
+ def compile_insert values
im = InsertManager.new @engine
im.insert values
- @engine.connection.insert im.to_sql
+ im
end
- def delete
+ # 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
+switch to `compile_insert`
+ eowarn
+ end
+ @engine.connection.insert compile_insert(values).to_sql
+ end
+
+ def compile_delete
dm = DeleteManager.new @engine
dm.wheres = @ctx.wheres
dm.from @ctx.froms
- @engine.connection.delete dm.to_sql, 'AREL'
+ 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'
end
end
end