Commit | Line | Data |
ef0d6124 |
1 | use strict; |
2 | use warnings; |
3 | |
747f7c21 |
4 | use Test::More tests => 5; |
ef0d6124 |
5 | use Test::Exception; |
6 | |
7 | use_ok('SQL::Abstract') or BAIL_OUT( "$@" ); |
8 | |
9 | my $sqla = SQL::Abstract->create(1); |
10 | |
11 | throws_ok { |
12 | $sqla->dispatch( |
13 | { -type => 'expr', op => '==', |
14 | args => [ |
15 | { -type => 'name', args => [qw/me id/] }, |
16 | { -type => 'alias', ident => { -type => 'name', args => [qw/me id/] }, as => 'bar' } |
17 | ] |
18 | } |
19 | ) |
20 | } qr/^'alias' is not a valid AST type in an expression/, "Error from invalid part in where"; |
21 | |
22 | throws_ok { |
23 | $sqla->dispatch( |
24 | { -type => 'expr', op => '~' } |
25 | ) |
747f7c21 |
26 | } qr/^'~' is not a valid operator in an expression/; |
27 | |
28 | local $TODO = "Work out how to get nice errors for these"; |
29 | |
30 | throws_ok { |
31 | $sqla->dispatch( |
32 | { -type => 'alias', ident => 2 } # no as, inavlid ident |
33 | ) |
34 | } qr/foobar/, "alias: no as, invalid ident"; |
35 | |
36 | throws_ok { |
37 | $sqla->dispatch( |
38 | { -type => 'alias', iden => { -type => 'name', args => ['id'] }, as => 'foo' } # iden not ident |
39 | ) |
40 | } qr/foobar/, "alias: iden instead of ident"; |
ef0d6124 |
41 | |