Home » Database » DB_DataObject » Bug #3943
boolean data type broken for PostgreSQL
Details
| Submitted | 2005-03-24 14:26 UTC |
|---|---|
| From | bugs at niluje dot net |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 5.0.3 |
| OS | any |
| Roadmaps | (Not assigned) |
Comments
[2005-03-24 14:26 UTC] bugs at niluje dot net
Description:
------------
The changes in 1.7.12 broke boolean usage with postgresql.
it's not the first time that an upgrade breaks all my intranet applications, i'm very concerned with the "quality" of PEAR libraries. Every time it's getting harder for me to justify the usage of php against java for critical entreprise process.
thanks
Reproduce code:
---------------
some dataobject:
$dao->bool_field = false;
$dao->insert();
Expected result:
----------------
SQL with version 1.7.11 :
INSERT INTO xxxxx (boolean_field) VALUES(FALSE);
the correct SQL syntax with pgsql would be IS FALSE, IS TRUE
or =TRUE, =FALSE
it would work with ='0' or ='1' but it's not great.
Actual result:
--------------
SQL with version 1.7.12 :
INSERT INTO xxxxx (boolean_field) VALUES('');
note that if you use
$dao->boolean_field = true; the SQL will be :
INSERT INTO xxxxx (boolean_field) VALUES('1');
[2005-03-24 15:06 UTC] bugs at niluje dot net
upgraded to 1.7.13 File truncated ?
Parse error: parse error, unexpected $ in /usr/share/php/DB/DataObject.php on line 3691
// technially 4.3.2RC1 was broken!!
// looks like 4.3.3 may have problems too....
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
if ((phpversion() != '4.3.2-RC1') && (version_compare( phpversion(), "4.3.1") > 0)) {
if (version_compare( phpversion(), "5") < 0) {
overload('DB_DataObject');
}
$GLOBALS['_DB_DATAOBJECT']['OVERL
[2005-03-24 15:18 UTC] bugs at niluje dot net
The fix is done using boolean_field='0' / ='1'
why not use =TRUE =FALSE
?
[2005-03-25 10:24 UTC] bugs at niluje dot net
why do you want to use 0 or 1, use TRUE or FALSE. it's much easier to read.