%{super()},
in => $self->can('_in'),
not_in => $self->can('_in'),
+ between => $self->can('_between'),
+ not_between => $self->can('_between'),
and => $self->can('_recurse_where'),
or => $self->can('_recurse_where'),
map { +"$_" => $self->can("_$_") } qw/
")";
}
+ method _between(AST $ast) {
+
+ my ($field,@values) = @{$ast->{args}};
+
+ my $not = ($ast->{op} =~ /^not_/) ? " NOT" : "";
+ croak "between requires 3 arguments: " . dump($ast)
+ unless @values == 2;
+
+ return $self->_expr($field) .
+ $not .
+ " BETWEEN " .
+ join(" AND ", map { $self->dispatch($_) } @values );
+ }
+
# 'constants' that are portable across DBs
method _false($ast?) { "0 = 1" }
method _true($ast?) { "1 = 1" }
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 4;
use Test::Differences;
use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
), "last_insert_id()",
"last_insert_id";
+is $sqla->dispatch(
+ { -type => 'expr',
+ op => 'between',
+ args => [
+ {-type => name => args => [qw/me id/] },
+ { -type => 'value', value => 500 },
+ { -type => 'value', value => 599 },
+ ],
+ }
+), "me.id BETWEEN ? AND ?",
+ "between";
+