From: Matt S Trout Date: Sat, 12 Oct 2019 20:15:22 +0000 (+0000) Subject: add SQLA::More compat shim X-Git-Tag: v1.90_03~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=49781e5eb9e8ba816c26e5649f388be92a527e46;p=dbsrgits%2FSQL-Abstract.git add SQLA::More compat shim --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 12c2c0c..91d1898 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -320,6 +320,31 @@ sub new { $self->_expand_ident(ident => $body); }); } + if ($class->isa('SQL::Abstract::More')) { + $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}; + if ( + ref($type) eq 'HASH' and ref($val) eq 'HASH' + and keys %$type == 1 and keys %$val == 1 + and (keys %$type)[0] eq (keys %$val)[0] + ) { + ($op) = keys %$type; + ($type) = values %$type; + ($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_op_andor($logop, $v, $k); + }; + $opt{render}{bind} = sub { + return [ '?', map +(ref($_->[0]) ? $_ : $_->[1]), $_[2] ] + }; + } } if ($opt{lazy_join_sql_parts}) {