# GLOBALS
#======================================================================
-our $VERSION = '1.61';
+our $VERSION = '1.62';
# This would confuse some packagers
#$VERSION = eval $VERSION; # numify for warning-free dev releases
$logic ||= 'and';
local $self->{_nested_func_lhs} = $self->{_nested_func_lhs};
- $self->{_nested_func_lhs} ||= $k;
my ($all_sql, @all_bind);
},
FALLBACK => sub { # CASE: col => {op/func => $stuff}
+
+ # if we are starting to nest and the first func is not a cmp op
+ # assume equality
+ my $prefix;
+ unless ($self->{_nested_func_lhs}) {
+ $self->{_nested_func_lhs} = $k;
+ $prefix = $self->{cmp} unless $op =~ $self->{cmp_ops};
+ }
+
($sql, @bind) = $self->_where_func_generic ($op, $val);
- $sql = join ' ', $self->_convert($self->_quote($k)), $sql;
+ $sql = join ' ', $self->_convert($self->_quote($k)), $prefix||(), $sql;
},
});
}
sub _METHOD_FOR_refkind {
my ($self, $meth_prefix, $data) = @_;
- my $method = List::Util::first {$_} map {$self->can($meth_prefix."_".$_)}
- $self->_try_refkind($data)
- or puke "cannot dispatch on '$meth_prefix' for ".$self->_refkind($data);
- return $method;
+
+ my $method;
+ for ($self->_try_refkind($data)) {
+ $method = $self->can($meth_prefix."_".$_)
+ and last;
+ }
+
+ return $method || puke "cannot dispatch on '$meth_prefix' for ".$self->_refkind($data);
}
sub _SWITCH_refkind {
my ($self, $data, $dispatch_table) = @_;
- my $coderef = List::Util::first {$_} map {$dispatch_table->{$_}}
- $self->_try_refkind($data)
- or puke "no dispatch entry for ".$self->_refkind($data);
+ my $coderef;
+ for ($self->_try_refkind($data)) {
+ $coderef = $dispatch_table->{$_}
+ and last;
+ }
+
+ puke "no dispatch entry for ".$self->_refkind($data)
+ unless $coderef;
+
$coderef->();
}