Get select sort of working again
[dbsrgits/SQL-Abstract-2.0-ish.git] / t / 900_errors.t
CommitLineData
ef0d6124 1use strict;
2use warnings;
3
747f7c21 4use Test::More tests => 5;
ef0d6124 5use Test::Exception;
6
7use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
8
9my $sqla = SQL::Abstract->create(1);
10
11throws_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
22throws_ok {
23 $sqla->dispatch(
24 { -type => 'expr', op => '~' }
25 )
747f7c21 26} qr/^'~' is not a valid operator in an expression/;
27
28local $TODO = "Work out how to get nice errors for these";
29
30throws_ok {
31 $sqla->dispatch(
32 { -type => 'alias', ident => 2 } # no as, inavlid ident
33 )
34} qr/foobar/, "alias: no as, invalid ident";
35
36throws_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