From: Matt S Trout Date: Wed, 27 Mar 2019 03:25:15 +0000 (+0000) Subject: better in handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3445a1e75e7b24baf59387b11396b8e0ffe5edc5;p=scpubgit%2FQ-Branch.git better in handling --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index ca4b54f..40cb08c 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -202,6 +202,8 @@ sub new { -or => '_expand_op_andor', -nest => '_expand_nest', -bind => sub { shift; +{ @_ } }, + -in => '_expand_in', + -not_in => '_expand_in', }; $opt{expand_op} = { @@ -992,7 +994,10 @@ sub _expand_between { } sub _expand_in { - my ($self, $op, $vv, $k) = @_; + my ($self, $raw, $vv, $k) = @_; + $k = shift @{$vv = [ @$vv ]} unless defined $k; + local our $Cur_Col_Meta = $k; + my $op = $self->_normalize_op($raw); if (my $literal = is_literal_value($vv)) { my ($sql, @bind) = @$literal; my $opened_sql = $self->_open_outer_paren($sql); diff --git a/t/05in_between.t b/t/05in_between.t index b435c48..44e4034 100644 --- a/t/05in_between.t +++ b/t/05in_between.t @@ -279,8 +279,9 @@ my @in_between_tests = ( }, { - where => { -in => [42] }, - throws => qr/Illegal use of top-level '-in'/, + where => { -in => [ 'bob', 4, 2 ] }, + stmt => ' WHERE (bob IN (?, ?))', + bind => [ 4, 2 ], test => 'Top level -in', }, {