From: Peter Rabbitson Date: Wed, 24 Nov 2010 16:42:56 +0000 (+0100) Subject: Fix retardation in -between bind handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e5cbf5124ea9704c01824f32b70072c39f69179;p=scpubgit%2FQ-Branch.git Fix retardation in -between bind handling --- diff --git a/Changes b/Changes index 2d02973..54b5ee1 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for SQL::Abstract - Fix parsing of foo.* in SQLA::Tree + - Fix bindtype fail when using -between with arrayrefref literals revision 1.71 2010-11-09 ---------------------------- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 0e29467..5944c62 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -890,7 +890,7 @@ sub _where_field_BETWEEN { foreach my $val (@$vals) { my ($sql, @bind) = $self->_SWITCH_refkind($val, { SCALAR => sub { - return ($placeholder, $val); + return ($placeholder, $self->_bindtype($k, $val) ); }, SCALARREF => sub { return $$val; @@ -914,7 +914,7 @@ sub _where_field_BETWEEN { return ( (join $and, @all_sql), - $self->_bindtype($k, @all_bind), + @all_bind ); }, FALLBACK => sub { diff --git a/t/05in_between.t b/t/05in_between.t index 79f8c29..22218c0 100644 --- a/t/05in_between.t +++ b/t/05in_between.t @@ -83,6 +83,32 @@ my @in_between_tests = ( bind => [1, 2, 1, 2, 'stuff'], test => '-between POD test', }, + { + args => { bindtype => 'columns' }, + where => { + start0 => { -between => [ 1, { -upper => 2 } ] }, + start1 => { -between => \["? AND ?", [ start1 => 1], [start1 => 2] ] }, + start2 => { -between => \"lower(x) AND upper(y)" }, + start3 => { -between => [ + \"lower(x)", + \["upper(?)", [ start3 => 'stuff'] ], + ] }, + }, + stmt => "WHERE ( + ( start0 BETWEEN ? AND UPPER ? ) + AND ( start1 BETWEEN ? AND ? ) + AND ( start2 BETWEEN lower(x) AND upper(y) ) + AND ( start3 BETWEEN lower(x) AND upper(?) ) + )", + bind => [ + [ start0 => 1 ], + [ start0 => 2 ], + [ start1 => 1 ], + [ start1 => 2 ], + [ start3 => 'stuff' ], + ], + test => '-between POD test', + }, { parenthesis_significant => 1,