Commit | Line | Data |
704c5138 |
1 | use strict; |
2 | use warnings; |
3 | |
d0ad3a92 |
4 | use Test::More tests => 4; |
704c5138 |
5 | use Test::Differences; |
6 | |
7 | use_ok('SQL::Abstract') or BAIL_OUT( "$@" ); |
8 | |
9 | my $sqla = SQL::Abstract->create(1); |
10 | |
11 | is $sqla->dispatch( |
cbcfedc1 |
12 | { -type => 'join', |
d0ad3a92 |
13 | args => [ |
14 | {-type => name => args => [qw/bar/]}, |
15 | {-type => name => args => [qw/foo/]}, |
16 | ], |
747f7c21 |
17 | on => { |
18 | -type => 'expr', |
19 | op => '==', |
20 | args => [ |
21 | { -type => 'name', args => [qw/foo id/] }, |
22 | { -type => 'name', args => [qw/me foo_id/] }, |
23 | ] |
24 | } |
cbcfedc1 |
25 | } |
d0ad3a92 |
26 | ), "bar JOIN foo ON (foo.id = me.foo_id)", |
704c5138 |
27 | "simple join clause"; |
28 | |
cbcfedc1 |
29 | is $sqla->dispatch( |
30 | { -type => 'join', |
d0ad3a92 |
31 | args => [ |
32 | {-type => name => args => [qw/fnord/]}, |
33 | {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' } |
34 | ], |
747f7c21 |
35 | using => { -type => 'name', args => [qw/foo_id/] }, |
cbcfedc1 |
36 | } |
d0ad3a92 |
37 | ), "fnord JOIN foo AS bar USING (foo_id)", |
cbcfedc1 |
38 | "using join clause"; |
d0ad3a92 |
39 | |
40 | |
41 | is $sqla->dispatch( |
42 | { -type => 'join', |
43 | join_type => 'LEFT', |
44 | args => [ |
45 | {-type => name => args => [qw/fnord/]}, |
46 | {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' } |
47 | ], |
48 | using => { -type => 'name', args => [qw/foo_id/] }, |
49 | } |
50 | ), "fnord LEFT JOIN foo AS bar USING (foo_id)", |
51 | "using left join clause"; |