Subject: | Please accept "" for boolean false value |
Date: | Wed, 26 Aug 2020 01:18:51 +0100 |
To: | bug-dbd-pg [...] rt.cpan.org |
From: | Ian Jackson <v13mx2 [...] fyvzl.net> |
Perl's canonical representation for booleans is 1 for true and '' for
false. This is returned by all of Perl's boolean operators such as
==, eq, &&, ||, and, or, !, etc.
But attempting to pass such a value to DBD::Pg for use in a boolean
column results in this error:
DBD::Pg::st execute failed: ERROR: invalid input syntax for type boolean: ""
This is quite unfortunate.
AFAICT from the docs, DBD::Pg already accepts many different values
for false, and it seems that accepting '' too would be
straightforward. There doesn't seem to be a downside.
In the meantime, the workaround is to pass
$somebool + 0
rather than
$somebool + 1
in boolean columns.
--
Ian Jackson <ijackson@chiark.greenend.org.uk> These opinions are my own.
Pronouns: they/he. If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.