From: Norbert Buchmuller Date: Thu, 20 Nov 2008 11:32:24 +0000 (+0000) Subject: Support for the { operator => \"..." } construct (to embed literal SQL). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=145fbfc8e22d81d833a4845a21c48656382ac33f;p=scpubgit%2FQ-Branch.git Support for the { operator => \"..." } construct (to embed literal SQL). --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 2a74a7f..9959486 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -529,6 +529,13 @@ sub _where_hashpair_HASHREF { ($sql, @bind) = $self->_where_field_op_ARRAYREF($k, $op, $val); } + # CASE: col => {op => \$scalar} + elsif (ref $val eq 'SCALAR') { + $sql = join ' ', $self->_convert($self->_quote($k)), + $self->_sqlcase($op), + $$val; + } + # CASE: col => {op => undef} : sql "IS (NOT)? NULL" elsif (! defined($val)) { my $is = ($op =~ $self->{equality_op}) ? 'is' : @@ -2066,6 +2073,10 @@ support for literal SQL through the C<< \ [$sql, bind] >> syntax. =item * +support for the { operator => \"..." } construct (to embed literal SQL) + +=item * + added -nest1, -nest2 or -nest_1, -nest_2, ... =item * diff --git a/t/01generate.t b/t/01generate.t index 4d98bb7..18e015c 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -344,6 +344,14 @@ my @tests = ( stmt_q => 'UPDATE `test` SET `a` = ?, `b` = ?', bind => [[a => 1], [b => [1, 1, 2, 3, 5, 8]]], }, + #37 + { + func => 'select', + args => ['test', '*', { a => {'>', \'1 + 1'}, b => 8 }], + stmt => 'SELECT * FROM test WHERE ( a > 1 + 1 AND b = ? )', + stmt_q => 'SELECT * FROM `test` WHERE ( `a` > 1 + 1 AND `b` = ? )', + bind => [8], + }, );