blob: b672f88ecf61c7886012172a9bd3fbb0ee098715 (
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
|
require 'helper'
module Arel
module Visitors
describe 'the join_sql visitor' do
before do
@visitor = ToSql.new Table.engine
@visitor.extend(JoinSql)
end
it 'should visit string join' do
sql = @visitor.accept Nodes::StringJoin.new('omg')
sql.must_be_like "'omg'"
end
describe 'inner join' do
it 'should visit left if left is a join' do
t = Table.new :users
sm = t.select_manager
sm.join(t).on(t[:id]).join(t).on(t[:id])
sm.join_sql.must_be_like %{
INNER JOIN "users" ON "users"."id"
INNER JOIN "users" ON "users"."id"
}
end
end
describe 'outer join' do
it 'should visit left if left is a join' do
t = Table.new :users
sm = t.select_manager
sm.join(t, Nodes::OuterJoin).on(t[:id]).join(
t, Nodes::OuterJoin).on(t[:id])
sm.join_sql.must_be_like %{
LEFT OUTER JOIN "users" ON "users"."id"
LEFT OUTER JOIN "users" ON "users"."id"
}
end
end
end
end
end
|