From: Fabrizio Gennari Date: Fri, 6 Apr 2018 08:58:30 +0000 (+0200) Subject: Do not replace the literal string '0' with '' X-Git-Tag: v1.86~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=417dd15e9d8e3a2575614757202bcfb4bbe9c660;p=dbsrgits%2FSQL-Abstract.git Do not replace the literal string '0' with '' --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index bd512ca..58244e8 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -523,7 +523,7 @@ sub where { # where ? my ($sql, @bind) = $self->_recurse_where($where); - $sql = $sql ? $self->_sqlcase(' where ') . "( $sql )" : ''; + $sql = (defined $sql and length $sql) ? $self->_sqlcase(' where ') . "( $sql )" : ''; # order by? if ($order) { diff --git a/t/02where.t b/t/02where.t index 6d89b8c..229770b 100644 --- a/t/02where.t +++ b/t/02where.t @@ -386,6 +386,11 @@ my @handle_tests = ( stmt => " WHERE ( (NOT ( c AND (NOT ( (NOT a = ?) AND (NOT b) )) )) ) ", bind => [ 1 ], }, + { + where => \"0", + stmt => " WHERE ( 0 ) ", + bind => [ ], + }, ); for my $case (@handle_tests) {