From: Matt S Trout Date: Fri, 5 Apr 2019 21:45:16 +0000 (+0000) Subject: pass -op expansion to expand_op handler, fix in X-Git-Tag: v1.90_01~259 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d8650614d3866beb43f746b8492dab446400be5;p=dbsrgits%2FSQL-Abstract.git pass -op expansion to expand_op handler, fix in --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index df523f2..934459b 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -873,6 +873,9 @@ sub _expand_row { sub _expand_op { my ($self, undef, $args) = @_; my ($op, @opargs) = @$args; + if (my $exp = $self->{expand_op}{$op}) { + return $self->$exp($op, \@opargs); + } +{ -op => [ $op, map $self->expand_expr($_), @opargs ] }; } @@ -978,7 +981,7 @@ sub _expand_in { my $opened_sql = $self->_open_outer_paren($sql); return +{ -op => [ $op, $self->expand_expr($k, -ident), - [ { -literal => [ $opened_sql, @bind ] } ] + { -literal => [ $opened_sql, @bind ] } ] }; } my $undef_err = @@ -997,7 +1000,7 @@ sub _expand_in { return +{ -op => [ $op, $self->expand_expr($k, -ident), - \@rhs + @rhs ] }; } @@ -1142,13 +1145,13 @@ sub _render_op_between { sub _render_op_in { my ($self, $op, $args) = @_; - my ($lhs, $rhs) = @$args; + my ($lhs, @rhs) = @$args; my @in_bind; my @in_sql = map { my ($sql, @bind) = $self->render_aqt($_); push @in_bind, @bind; $sql; - } @$rhs; + } @rhs; my ($lhsql, @lbind) = $self->render_aqt($lhs); return ( $lhsql.' '.$self->_sqlcase(join ' ', split '_', $op).' ( ' diff --git a/t/05in_between.t b/t/05in_between.t index 9d168c4..5bcbe55 100644 --- a/t/05in_between.t +++ b/t/05in_between.t @@ -325,6 +325,13 @@ my @in_between_tests = ( bind => [], test => 'Top level -is ok', }, + { + where => { -op => [ in => x => 1, 2, 3 ] }, + stmt => ' WHERE x IN (?, ?, ?)', + bind => [ 1, 2, 3 ], + test => 'Raw -op passes through correctly' + }, + ); for my $case (@in_between_tests) {