Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #10326 Update on record using update($orignal) method with null values inserts 0's
Submitted: 2007-03-11 01:25 UTC
From: spin Assigned:
Status: Open Package: DB_DataObject (version 1.8.5)
PHP Version: 5.2.0 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2007-03-11 01:25 UTC] spin (Jake Caudill)
Description: ------------ I've done a get(), the get returns null values for the fields in question. after doing the get, I do not change any values in the form. I submit a form to edit a record in the DB. The database table has several fields that allow NULL values. the update is of the following form. $object->update($original) This bug has been reported before and is still a problem here using mysql. https://pear.php.net/bugs/bug.php?id=4919&edit=2 Test script: --------------- I'm sorry but i do not have the skills needed to make a simple test case, I am instead posting debug output from DBDO that shows the state of the original object and the object to be updated and that they are identical with null values in place. $DO_ORIGINAL===========DO_TblProperties Object ( [__table] => tblProperties [intPropertyID] => 3 [decSqFt] => [intHalfBaths] => [intDeposit] => [intPriceFurnished] => [intLeaseLength] => $DO_RENTALS===========DO_TblProperties Object ( [__table] => tblProperties [intPropertyID] => 3 [decSqFt] => [intHalfBaths] => [intDeposit] => [intPriceFurnished] => [intLeaseLength] => Expected result: ---------------- I expect that the DB record would not be updated since the original object and the object to update are identical and have empty values(null) that are allowed to be null in the DB. Actual result: -------------- DO_TblProperties : QUERY : UPDATE `tblProperties` SET `decSqFt` = 0 , `intHalfBaths` = 0 , `intDeposit` = 0 , `intPriceFurnished` = 0 , `intLeaseLength` = 0 WHERE ( `tblProperties`.`intPropertyID` = 3 )

Comments

 [2007-03-12 01:36 UTC] alan_k (Alan Knowles)
Can you do: mysqldump -d yourdatabase tblProperties Regards Alan
 [2007-03-12 02:24 UTC] spin (Jake Caudill)
-- -- Table structure for table `tblProperties` -- DROP TABLE IF EXISTS `tblProperties`; CREATE TABLE `tblProperties` ( `intPropertyID` mediumint(6) unsigned NOT NULL auto_increment, `intUserID` smallint(5) unsigned NOT NULL, `intTypeID` tinyint(2) unsigned NOT NULL, `txtAptName` varchar(50) NOT NULL, `txtAddress` varchar(75) NOT NULL, `txtCounty` varchar(35) NOT NULL, `txtCity` varchar(35) NOT NULL, `intZip` mediumint(5) unsigned NOT NULL, `decSqFt` decimal(5,2) unsigned default NULL, `intBedrooms` tinyint(2) unsigned NOT NULL, `intFullBaths` tinyint(2) unsigned NOT NULL, `intHalfBaths` tinyint(2) unsigned default NULL, `intPetCat` tinyint(1) unsigned NOT NULL default '0', `intPetDog` tinyint(1) unsigned NOT NULL default '0', `txtDescription` text NOT NULL, `txtOtherInfo` text, `intOccupancy` tinyint(2) unsigned NOT NULL, `bitListed` tinyint(1) unsigned default '1', `bitReferences` tinyint(1) unsigned NOT NULL default '0', `intUnitsAvail` smallint(4) unsigned NOT NULL default '1', `dtePosted` datetime NOT NULL, `dteAvailable` date NOT NULL, `intDeposit` mediumint(5) unsigned default NULL, `intPrice` mediumint(5) unsigned NOT NULL, `intPriceFurnished` mediumint(5) unsigned default NULL, `intLeaseLength` tinyint(2) unsigned default NULL, `intLatitude` decimal(6,6) default NULL, `intLongitude` decimal(6,6) default NULL, `intDefImageID` int(8) unsigned default NULL, PRIMARY KEY (`intPropertyID`), KEY `intRenterID` (`intUserID`,`intTypeID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 [2008-03-23 09:25 UTC] doconnor (Daniel O'Connor)
Alan, is this a dupe of bug #4919 ?
 [2008-03-23 09:33 UTC] alan_k (Alan Knowles)
I think this one's a realy bug (it's a dupe of another bug, but I cant remember which one. Basically update($xx) probably does not check null value against null value... it may not be feasible to fix this.. - but may be worth a go... Leaving it as open untill I get time to look at it.