From: Dagfinn Ilmari Mannsåker Date: Wed, 4 Dec 2013 15:16:13 +0000 (+0000) Subject: Document and test non-reference { -in => ... } X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dfd24428b7952b71d617954940e62eba908139d;p=scpubgit%2FQ-Branch.git Document and test non-reference { -in => ... } Also test the documented but untested { -in => [] } optimisation. --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 4609e5d..de10fcd 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -2231,7 +2231,8 @@ would generate: )"; @bind = ('2000'); - +Finally, if the argument to C<-in> is not a reference, it will be +treated as a single-element array. Another pair of operators is C<-between> and C<-not_between>, used with an arrayref of two values: diff --git a/t/01generate.t b/t/01generate.t index 60dea0d..f015d27 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -538,6 +538,14 @@ my @tests = ( stmt_q => 'SELECT * FROM `test` WHERE ( `Y` = ( MAX( LENGTH( MIN ? ) ) ) )', bind => [[Y => 'x']], }, + { + func => 'select', + args => ['test', '*', { a => { -in => [] }, b => { -not_in => [] }, c => { -in => 42 } }], + stmt => 'SELECT * FROM test WHERE ( 0=1 AND 1=1 AND c IN ( ? ))', + stmt_q => 'SELECT * FROM `test` WHERE ( 0=1 AND 1=1 AND `c` IN ( ? ))', + bind => [ 42 ], + }, + ); for my $t (@tests) {