override _build_where_dispatch_table {
return {
%{super()},
- -in => $self->can('_in'),
- -not_in => $self->can('_in'),
- map { +"-$_" => $self->can("_$_") } qw/
+ in => $self->can('_in'),
+ not_in => $self->can('_in'),
+ map { +"$_" => $self->can("_$_") } qw/
value
name
true
}
- method _value(ArrayAST $ast) {
- my ($undef, $value) = @$ast;
+ method _value(HashAST $ast) {
- $self->add_bind($value);
+ $self->add_bind($ast->{value});
return "?";
}
return join(" $OP ", @output);
}
- method _where_component(ArrayRef $ast) {
- my $op = $ast->[0];
+ method _where_component(HashAST $ast) {
+ my $op = $ast->{-type};
if (my $code = $self->lookup_where_dispatch($op)) {
}
+ method _expr(HashAST $ast) {
+ my $op = $ast->{op};
+ my $meth = $self->lookup_where_dispatch($op) || confess "Invalid operator '$op'";
+
+ $meth->($self, $ast);
+ }
- method _binop(ArrayRef $ast) {
- my ($op, $lhs, $rhs) = @$ast;
+ method _binop(HashAST $ast) {
+ my ($lhs, $rhs) = @{$ast->{args}};
+ my $op = $ast->{op};
join (' ', $self->_where_component($lhs),
$self->binop_mapping($op) || croak("Unknown binary operator $op"),
my $sqla = SQL::Abstract->create(1);
is $sqla->dispatch(
- [ -where =>
- [ '>', [-name => qw/me id/], [-value => 500 ] ]
- ]
-), "WHERE me.id > ?",
+ { -type => 'expr',
+ op => '>',
+ args => [
+ {-type => name => args => [qw/me id/] },
+ { -type => 'value', value => 500 }
+ ]
+ }
+), "me.id > ?",
"simple where clause";
-
+__END__
is $sqla->dispatch(
[ -in => [ ] ]
), "0 = 1", "emtpy -in";