From: Matt S Trout Date: Sun, 13 Oct 2019 02:21:49 +0000 (+0000) Subject: rewire sqla::More code to use only public methods X-Git-Tag: v1.90_03~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e33b58e055c12555fa81a5ad669d5e6a459562f9;p=dbsrgits%2FSQL-Abstract.git rewire sqla::More code to use only public methods --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 91d1898..5c7282a 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -155,6 +155,7 @@ our %Defaults = ( (map +($_ => '_expand_op_is'), ('is', 'is_not')), (map +($_ => __PACKAGE__->make_unop_expander("_expand_${_}")), qw(ident value nest)), + bind => __PACKAGE__->make_unop_expander(sub { +{ -bind => $_[2] } }), }, render => { (map +($_, "_render_$_"), @@ -321,11 +322,12 @@ sub new { }); } if ($class->isa('SQL::Abstract::More')) { + my $orig = $opt{expand_op}{or}; $opt{expand_op}{or} = sub { my ($self, $logop, $v, $k) = @_; if ($k and ref($v) eq 'ARRAY') { my ($type, $val) = @$v; - my $op = $self->{cmp}; + my $op; if ( ref($type) eq 'HASH' and ref($val) eq 'HASH' and keys %$type == 1 and keys %$val == 1 @@ -336,10 +338,12 @@ sub new { ($val) = values %$val; } if ($self->is_bind_value_with_type(my $v = [ $type, $val ])) { - return $self->_expand_hashpair($k, { $op, { -bind => $v } }); + return $self->expand_expr( + { $k, map +($op ? { $op => $_ } : $_), { -bind => $v } } + ); } } - return $self->_expand_op_andor($logop, $v, $k); + return $self->$orig($logop, $v, $k); }; $opt{render}{bind} = sub { return [ '?', map +(ref($_->[0]) ? $_ : $_->[1]), $_[2] ]