{ regex => qr/^ value $/xi, handler => '_where_op_VALUE' },
{ regex => qr/^ op $/xi, handler => '_where_op_OP' },
{ regex => qr/^ bind $/xi, handler => '_where_op_BIND' },
+ { regex => qr/^ literal $/xi, handler => '_where_op_LITERAL' },
);
#======================================================================
}
return { '-'.$logic => \@res };
}
+ if (my $literal = is_literal_value($expr)) {
+ return +{ -literal => $literal };
+ }
return $expr;
}
sub _expand_expr_hashpair {
my ($self, $k, $v, $logic) = @_;
unless (defined($k) and length($k)) {
- if (defined($k) and is_literal_value($v)) {
+ if (defined($k) and my $literal = is_literal_value($v)) {
belch 'Hash-pairs consisting of an empty string with a literal are deprecated, and will be removed in 2.0: use -and => [ $literal ] instead';
- return $v;
+ return { -literal => $literal };
}
puke "Supplying an empty left hand side argument is not supported";
}
]
};
}
+ if (ref($v) eq 'HASH' and keys %$v > 1) {
+ return { -and => [
+ map $self->_expand_expr_hashpair($k => { $_ => $v->{$_} }),
+ sort keys %$v
+ ] };
+ }
if (ref($v) eq 'ARRAY') {
return $self->{sqlfalse} unless @$v;
$self->_debug("ARRAY($k) means distribute over elements");
return \$literal;
}
my ($sql, @bind) = @$literal;
- return \[ $self->_quote($k).' '.$sql, @bind ];
+ if ($self->{bindtype} eq 'columns') {
+ for (@bind) {
+ if (!defined $_ || ref($_) ne 'ARRAY' || @$_ != 2) {
+ puke "bindtype 'columns' selected, you need to pass: [column_name => bind_value]"
+ }
+ }
+ }
+ return +{ -literal => [ $self->_quote($k).' '.$sql, @bind ] };
}
}
return { $k => $v };
return ($self->_convert('?'), $self->_bindtype(@$bind));
}
+sub _where_op_LITERAL {
+ my ($self, undef, $literal) = @_;
+ return @$literal;
+}
+
sub _where_hashpair_ARRAYREF {
my ($self, $k, $v) = @_;