Commit | Line | Data |
4ee32f41 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More tests => 3; |
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( |
12 | { -type => 'select', |
13 | from => [-alias => [-name => 'foo'] => 'me' ], |
14 | columns => [ -list => |
15 | [ -name => qw/me id/ ], |
16 | [ -alias => [ -name => qw/me foo_id/ ], 'foo' ], |
17 | ] |
18 | } |
19 | ), "SELECT me.id, me.foo_id AS foo FROM foo AS me", |
20 | "simple select clause"; |
21 | |
22 | is $sqla->dispatch( |
23 | { -type => 'select', |
24 | from => [-alias => [-name => 'foo'] => 'me' ], |
25 | columns => [ -list => |
26 | [ -name => qw/me id/ ], |
27 | [ -alias => [ -name => qw/me foo_id/ ], 'foo' ], |
28 | [ -name => qw/bar name/ ], |
29 | ], |
30 | join => { |
31 | tablespec => [-name => qw/bar/], |
32 | on => [ '==', [-name => qw/bar id/], [ -name => qw/me bar_id/ ] ], |
33 | } |
34 | } |
35 | ), "SELECT me.id, me.foo_id AS foo, bar.name FROM foo AS me JOIN bar ON (bar.id = me.bar_id)", |
36 | "select with join clause"; |
37 | |
38 | |