From: Dagfinn Ilmari Mannsåker Date: Sun, 28 Jun 2015 13:32:28 +0000 (+0100) Subject: Fix order clauses with bind parameters in ->where X-Git-Tag: v1.81_01~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=26fe4d30f09137780baf6fcf0297caace0124688;p=dbsrgits%2FSQL-Abstract.git Fix order clauses with bind parameters in ->where ->where was ignoring the bind parameters returned by ->_order_by --- diff --git a/Changes b/Changes index 771d14c..abc4287 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for SQL::Abstract + - Fix order clauses with bind parameters in ->where + revision 1.81 2014-10-25 ---------------------------- - Fix overly-enthusiastic parenthesis unroller (RT#99503) diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 7e12187..d213115 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -488,7 +488,9 @@ sub where { # order by? if ($order) { - $sql .= $self->_order_by($order); + my ($order_sql, @order_bind) = $self->_order_by($order); + $sql .= $order_sql; + push @bind, @order_bind; } return wantarray ? ($sql, @bind) : $sql; diff --git a/t/06order_by.t b/t/06order_by.t index 4236e70..42abaa6 100644 --- a/t/06order_by.t +++ b/t/06order_by.t @@ -110,7 +110,7 @@ my $sqlq = SQL::Abstract->new({quote_char => '`'}); for my $case( @cases) { my ($stat, @bind); - ($stat, @bind) = $sql->_order_by($case->{given}); + ($stat, @bind) = $sql->where(undef, $case->{given}); is_same_sql_bind ( $stat, \@bind, @@ -118,7 +118,7 @@ for my $case( @cases) { $case->{bind} || [], ); - ($stat, @bind) = $sqlq->_order_by($case->{given}); + ($stat, @bind) = $sqlq->where(undef, $case->{given}); is_same_sql_bind ( $stat, \@bind,