From: Matt S Trout Date: Tue, 26 Mar 2019 01:55:22 +0000 (+0000) Subject: extract _render_op_in X-Git-Tag: v2.000000~3^2~341 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11cb6e24767abbca243973d3854559f90d1a6dc5;p=dbsrgits%2FSQL-Abstract.git extract _render_op_in --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index cbf1268..44aa499 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1046,25 +1046,27 @@ sub _render_op_between { ); } +sub _render_op_in { + my ($self, $op, $args) = @_; + my ($lhs, $rhs) = @$args; + my @in_bind; + my @in_sql = map { + my ($sql, @bind) = $self->render_aqt($_); + push @in_bind, @bind; + $sql; + } @$rhs; + my ($lhsql, @lbind) = $self->render_aqt($lhs); + return ( + $lhsql.' '.$self->_sqlcase($op).' ( ' + .join(', ', @in_sql) + .' )', + @lbind, @in_bind + ); +} + our $RENDER_OP = { (map +($_ => '_render_op_between'), 'between', 'not between'), - (map +($_ => sub { - my ($self, $op, $args) = @_; - my ($lhs, $rhs) = @$args; - my @in_bind; - my @in_sql = map { - my ($sql, @bind) = $self->render_aqt($_); - push @in_bind, @bind; - $sql; - } @$rhs; - my ($lhsql, @lbind) = $self->render_aqt($lhs); - return ( - $lhsql.' '.$self->_sqlcase($op).' ( ' - .join(', ', @in_sql) - .' )', - @lbind, @in_bind - ); - }), 'in', 'not in'), + (map +($_ => '_render_op_in'), 'in', 'not in'), (map +($_ => '_render_unop_postfix'), 'is null', 'is not null', 'asc', 'desc', ),