Skip Menu |

This queue is for tickets about the SQL-Abstract CPAN distribution.

Report information
The Basics
Id: 125760
Status: new
Priority: 0/
Queue: SQL-Abstract

People
Owner: Nobody in particular
Requestors: fabrizio.ge [...] tiscali.it
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: ilmari [...] ilmari.org
Subject: literal string '0' is replaced by ''
Date: Thu, 5 Jul 2018 08:05:05 +0200
To: bug-SQL-Abstract [...] rt.cpan.org
From: Fabrizio Gennari <fabrizio.ge [...] tiscali.it>
In Perl, the literal string '0' is false. Because of this, if one uses the scalar ref "0", SQL::Abstract considers it a 'false' string and replaces it with an empty string. The tests below were made with version 1.85 perl -MSQL::Abstract -e 'my ($sql,@bind)=SQL::Abstract->new->where(\"1");CORE::say $sql' Value of $sql is  WHERE ( 1 ) as expected perl -MSQL::Abstract -e 'my ($sql,@bind)=SQL::Abstract->new->where(\"0");CORE::say $sql' Expected value of $sql is  WHERE ( 0 ) Actual is an empty string perl -MSQL::Abstract -e 'my ($sql,@bind)=SQL::Abstract->new->where({-bool=>\"1"});CORE::say $sql' Value of $sql is  WHERE ( 1 ) as expected perl -MSQL::Abstract -e 'my ($sql,@bind)=SQL::Abstract->new->where({-bool=>\"0"});CORE::say $sql' Expected value of $sql is  WHERE ( 0 ) Actual is an empty string Strangely it works if the hash ref has other keys as well perl -MSQL::Abstract -e 'my ($sql,@bind)=SQL::Abstract->new->where({-bool=>\"0",a=>3});CORE::say $sql' Value of $sql is WHERE ( ( 0 AND a = ? ) ) and value of @bind is (3), as expected https://github.com/dbsrgits/sql-abstract/pull/14 is meant to fix this