mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
deprecating the "delete" method in favor of compile_delete
This commit is contained in:
parent
a8521641d5
commit
9e05f7e01b
4 changed files with 21 additions and 10 deletions
|
@ -12,6 +12,9 @@
|
|||
* Calls to `update` are deprecated. Please use `compile_update` then call
|
||||
`to_sql` on the resulting object and execute that SQL.
|
||||
|
||||
* Calls to `delete` are deprecated. Please use `compile_delete` then call
|
||||
`to_sql` on the resulting object and execute that SQL.
|
||||
|
||||
== 2.0.6 12/01/2010
|
||||
|
||||
* Bug Fixes
|
||||
|
|
|
@ -48,11 +48,21 @@ switch to `compile_insert`
|
|||
@engine.connection.insert compile_insert(values).to_sql
|
||||
end
|
||||
|
||||
def delete
|
||||
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 2.2.0. Please
|
||||
switch to `compile_delete`
|
||||
eowarn
|
||||
end
|
||||
@engine.connection.delete compile_delete.to_sql, 'AREL'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,10 +57,8 @@ module Arel
|
|||
table = Table.new :users
|
||||
fc = FakeCrudder.new
|
||||
fc.from table
|
||||
fc.delete
|
||||
fc.engine.calls.find { |method, _|
|
||||
method == :delete
|
||||
}.wont_be_nil
|
||||
stmt = fc.compile_delete
|
||||
assert_instance_of Arel::DeleteManager, stmt
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -390,9 +390,9 @@ module Arel
|
|||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new engine
|
||||
manager.from table
|
||||
manager.delete
|
||||
stmt = manager.compile_delete
|
||||
|
||||
engine.executed.last.must_be_like %{ DELETE FROM "users" }
|
||||
stmt.to_sql.must_be_like %{ DELETE FROM "users" }
|
||||
end
|
||||
|
||||
it "copies where" do
|
||||
|
@ -401,9 +401,9 @@ module Arel
|
|||
manager = Arel::SelectManager.new engine
|
||||
manager.from table
|
||||
manager.where table[:id].eq 10
|
||||
manager.delete
|
||||
stmt = manager.compile_delete
|
||||
|
||||
engine.executed.last.must_be_like %{
|
||||
stmt.to_sql.must_be_like %{
|
||||
DELETE FROM "users" WHERE "users"."id" = 10
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue