From: Matt S Trout Date: Sat, 8 Sep 2018 01:51:55 +0000 (+0000) Subject: initial introduction of literal op X-Git-Tag: v1.90_01~474 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa8d7bdb9eea3e86552a427f7396a01d13bc004e;p=dbsrgits%2FSQL-Abstract.git initial introduction of literal op --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index aa93bde..9ce3d1b 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -55,6 +55,7 @@ my @BUILTIN_UNARY_OPS = ( { regex => qr/^ value $/xi, handler => '_where_op_VALUE' }, { regex => qr/^ op $/xi, handler => '_where_op_OP' }, { regex => qr/^ bind $/xi, handler => '_where_op_BIND' }, + { regex => qr/^ literal $/xi, handler => '_where_op_LITERAL' }, ); #====================================================================== @@ -644,7 +645,14 @@ sub _expand_expr_hashpair { return \$literal; } my ($sql, @bind) = @$literal; - return \[ $self->_quote($k).' '.$sql, @bind ]; + if ($self->{bindtype} eq 'columns') { + for (@bind) { + if (!defined $_ || ref($_) ne 'ARRAY' || @$_ != 2) { + puke "bindtype 'columns' selected, you need to pass: [column_name => bind_value]" + } + } + } + return +{ -literal => [ $self->_quote($k).' '.$sql, @bind ] }; } } return { $k => $v }; @@ -1015,6 +1023,11 @@ sub _where_op_BIND { return ($self->_convert('?'), $self->_bindtype(@$bind)); } +sub _where_op_LITERAL { + my ($self, undef, $literal) = @_; + return @$literal; +} + sub _where_hashpair_ARRAYREF { my ($self, $k, $v) = @_;