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