blob: 27239eb1a8b1bb0025872b0ba757ae9b50a2c5ca (
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
|
require 'spec_helper'
module Arel
describe Lock do
before do
@relation = Table.new(:users)
end
describe '#to_sql' do
it "manufactures a simple select query lock" do
sql = @relation.lock.to_sql
adapter_is :mysql do
sql.should be_like(%Q{
SELECT `users`.`id`, `users`.`name`
FROM `users` FOR UPDATE
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
SELECT "users"."id", "users"."name"
FROM "users" FOR UPDATE
})
end
end
it "manufactures a select query locking with a given lock" do
sql = @relation.lock("LOCK IN SHARE MODE").to_sql
adapter_is :mysql do
sql.should be_like(%Q{
SELECT `users`.`id`, `users`.`name`
FROM `users` LOCK IN SHARE MODE
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
SELECT "users"."id", "users"."name"
FROM "users" LOCK IN SHARE MODE
})
end
end
end
end
end
|