blob: 302a13c688ef754856d70f30839679964ea33b4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
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 :oracle do
sql.should be_like(%Q{DELETE FROM "USERS"})
end
adapter_is_not :mysql, :oracle 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 :oracle do
sql.should be_like(%Q{
DELETE
FROM "USERS"
WHERE "USERS"."ID" = 1
})
end
adapter_is_not :mysql, :oracle 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 :oracle do
sql.should be_like(%Q{
DELETE
FROM "USERS"
WHERE ROWNUM <= 1
})
end
adapter_is_not :mysql, :oracle do
sql.should be_like(%Q{
DELETE
FROM "users"
LIMIT 1
})
end
end
end
end
end
|