{ regex => qr/^ op $/xi, handler => '_where_op_OP' },
{ regex => qr/^ bind $/xi, handler => '_where_op_BIND' },
{ regex => qr/^ literal $/xi, handler => '_where_op_LITERAL' },
+ { regex => qr/^ func $/xi, handler => '_where_op_FUNC' },
);
#======================================================================
if ($k eq '-value' and my $m = our $Cur_Col_Meta) {
return +{ -bind => [ $m, $v ] };
}
- if ($k eq '-op' or $k eq '-ident' or $k eq '-value' or $k eq '-bind' or $k eq '-literal') {
+ if ($k eq '-op' or $k eq '-ident' or $k eq '-value' or $k eq '-bind' or $k eq '-literal' or $k eq '-func') {
return { $k => $v };
}
- if (!ref($v)) {
+ if (
+ ref($v) eq 'HASH'
+ and keys %$v == 1
+ and (keys %$v)[0] =~ /^-/
+ ) {
+ my ($func) = $k =~ /^-(.*)$/;
+ return +{ -func => [ $func, $self->_expand_expr($v) ] };
+ }
+ if (!ref($v) or is_literal_value($v)) {
return +{ -op => [ $k =~ /^-(.*)$/, $self->_expand_expr($v) ] };
}
}
die "unhandled";
}
+sub _where_op_FUNC {
+ my ($self, undef, $rest) = @_;
+ my ($func, @args) = @$rest;
+ my @arg_sql;
+ my @bind = map {
+ my @x = @$_;
+ push @arg_sql, shift @x;
+ @x
+ } map [ $self->_recurse_where($_) ], @args;
+ return ($self->_sqlcase($func).'('.join(', ', @arg_sql).')', @bind);
+}
+
sub _where_op_BIND {
my ($self, undef, $bind) = @_;
return ($self->_convert('?'), $self->_bindtype(@$bind));