method _in($ast) {
my (undef, $field, @values) = @$ast;
+ return $self->_false if @values == 0;
return $self->dispatch($field) .
" IN (" .
join(", ", map { $self->dispatch($_) } @values ) .
method _generic_func(ArrayRef $ast) {
}
+ # 'constants' that are portable across DBs
+ method _false($ast?) { "0 = 1" }
+ method _true($ast?) { "1 = 1" }
+
}
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 18;
use Test::Differences;
use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
"Simple name generator";
is $sqla->dispatch(
+ [ '-false' ]
+), "0 = 1", "false value";
+
+is $sqla->dispatch(
+ [ '-true' ]
+), "1 = 1", "true value";
+
+is $sqla->dispatch(
[ -list =>
[ -name => qw/me id/],
[ -name => qw/me foo bar/],
is $sqla->dispatch(
+ [ -in => [ ] ]
+), "0 = 1", "emtpy -in";
+
+is $sqla->dispatch(
[ -where =>
[ '>', [-name => qw/me id/], [-value => 500 ] ]
]