our %Defaults = (
expand => {
- not => '_expand_not',
bool => '_expand_bool',
- and => '_expand_op_andor',
- or => '_expand_op_andor',
- nest => '_expand_nest',
- bind => '_expand_bind',
- in => '_expand_in',
- not_in => '_expand_in',
row => '_expand_row',
- between => '_expand_between',
- not_between => '_expand_between',
op => '_expand_op',
- (map +($_ => '_expand_op_is'), ('is', 'is_not')),
func => '_expand_func',
values => '_expand_values',
+ bind => '_expand_noop',
+ literal => '_expand_noop',
},
expand_op => {
'between' => '_expand_between',
}
}
- # an explicit node type is currently assumed to be expanded (this is almost
- # certainly wrong and there should be expansion anyway)
-
- if ($self->{render}{$op}) {
- return { $k => $v };
- }
-
- my $type = $self->{unknown_unop_always_func} ? -func : -op;
+ my $type = (
+ $self->{unknown_unop_always_func} && !$self->{render_op}{$op}
+ ? -func
+ : -op
+ );
{ # Old SQLA compat
and (keys %$v)[0] =~ /^-/
) {
$type = (
- (List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}})
+ (
+ (List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}})
+ or $self->{render_op}{$op}
+ )
? -op
: -func
)
}
}
- return +{ $type => [
- $op,
- ($type eq -func and ref($v) eq 'ARRAY')
- ? map $self->_expand_expr($_), @$v
- : $self->_expand_expr($v)
- ] };
+ if ($type eq -func and ref($v) eq 'ARRAY') {
+ return $self->_expand_expr({ -func => [ $op, @$v ] });
+ }
+
+ return $self->_expand_expr({ $type => [ $op, $v ] });
}
sub _expand_hashpair_cmp {
+{ -bind => [ our $Cur_Col_Meta, $_[2] ] };
}
-sub _expand_not {
- +{ -op => [ 'not', $_[0]->_expand_expr($_[2]) ] };
-}
-
sub _expand_row {
my ($self, undef, $args) = @_;
+{ -row => [ map $self->expand_expr($_), @$args ] };
return $self->_expand_expr($v);
}
-sub _expand_bind {
- my ($self, undef, $bind) = @_;
- return { -bind => $bind };
+sub _expand_noop {
+ my ($self, $type, $v) = @_;
+ return { "-${type}" => $v };
}
sub _expand_values {