blob: 3dc70d7dd6702aa93fc4bd8e31dd71973186a2b8 (
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
|
require 'spec_helper'
module Arel
module Visitors
describe 'the join_sql visitor' do
before do
@visitor = JoinSql.new Table.engine
end
describe 'inner join' do
it 'should visit left if left is a join' do
t = Table.new :users
join = Nodes::InnerJoin.new t, t, Nodes::On.new(t[:id])
j2 = Nodes::InnerJoin.new join, t, Nodes::On.new(t[:id])
@visitor.accept(j2).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
join = Nodes::OuterJoin.new t, t, Nodes::On.new(t[:id])
j2 = Nodes::OuterJoin.new join, t, Nodes::On.new(t[:id])
@visitor.accept(j2).must_be_like %{
LEFT OUTER JOIN "users" ON "users"."id"
LEFT OUTER JOIN "users" ON "users"."id"
}
end
end
end
end
end
|