Commit | Line | Data |
a0185af2 |
1 | use strict; |
2 | use warnings; |
3 | |
924d940e |
4 | use Test::More tests => 9; |
5bf8c024 |
5 | use Test::Differences; |
a0185af2 |
6 | |
7 | use_ok('SQL::Abstract') or BAIL_OUT( "$@" ); |
924d940e |
8 | use_ok('SQL::Abstract::AST::v1') or BAIL_OUT( "$@" ); |
a0185af2 |
9 | |
14774be0 |
10 | my $sqla = SQL::Abstract->create(1); |
0bf8a8c4 |
11 | |
12 | # TODO: once MXMS supports %args, use that here |
7a56723e |
13 | is $sqla->dispatch( { -type => 'name', args => [qw/me id/] }), "me.id", |
a0185af2 |
14 | "Simple name generator"; |
15 | |
7a56723e |
16 | is $sqla->dispatch( { -type => 'name', args => [qw/me */]}), |
4ee32f41 |
17 | "me.*", |
18 | "Simple name generator"; |
19 | |
20 | $sqla->quote_chars(['`']); |
21 | |
7a56723e |
22 | is $sqla->dispatch( { -type => 'name', args => [qw/me */]}), |
4ee32f41 |
23 | "`me`.*", |
24 | "Simple name generator"; |
25 | |
26 | $sqla->disable_quoting; |
27 | |
c314b35d |
28 | is $sqla->dispatch( |
7a56723e |
29 | { -type => 'false' } |
44cfd1f6 |
30 | ), "0 = 1", "false value"; |
31 | |
32 | is $sqla->dispatch( |
7a56723e |
33 | { -type => 'true' } |
44cfd1f6 |
34 | ), "1 = 1", "true value"; |
35 | |
36 | is $sqla->dispatch( |
7a56723e |
37 | { -type => 'list', |
38 | args => [ |
39 | { -type => name => args => [qw/me id/] }, |
40 | { -type => name => args => [qw/me foo bar/] }, |
41 | { -type => name => args => [qw/bar/] } |
42 | ] |
43 | } |
a0185af2 |
44 | ), "me.id, me.foo.bar, bar", |
45 | "List generator"; |
4769c837 |
46 | |
c314b35d |
47 | is $sqla->dispatch( |
7a56723e |
48 | { -type => 'alias', ident => { -type => name => args => [qw/me id/]}, as => "foobar" } |
4769c837 |
49 | ), "me.id AS foobar", |
50 | "Alias generator"; |
51 | |
d2582f0f |
52 | |