blob: 0b1e2329b63d4e87c1e6867dc2cb016d0fd6027f (
plain) (
tree)
|
|
require 'spec_helper'
module Arel
describe Deletion do
before do
@relation = Table.new(:users)
end
describe '#to_sql' do
it 'manufactures sql deleting a table relation' do
sql = Deletion.new(@relation).to_sql
adapter_is :mysql do
sql.should be_like(%Q{DELETE FROM `users`})
end
adapter_is_not :mysql do
sql.should be_like(%Q{DELETE FROM "users"})
end
end
it 'manufactures sql deleting a where relation' do
sql = Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql
adapter_is :mysql do
sql.should be_like(%Q{
DELETE
FROM `users`
WHERE `users`.`id` = 1
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
DELETE
FROM "users"
WHERE "users"."id" = 1
})
end
end
it "manufactures sql deleting a ranged relation" do
sql = Deletion.new(@relation.take(1)).to_sql
adapter_is :mysql do
sql.should be_like(%Q{
DELETE
FROM `users`
LIMIT 1
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
DELETE
FROM "users"
LIMIT 1
})
end
end
end
end
end
|