Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0.14, 1.1.6, 1.2.1
-
Fix Version/s: 1.2.2
-
Component/s: Connection
-
Labels:None
Description
I found this ticket on the old Trac system, but not on JIRA. It is still broken in the 1.1 branch, as of revision 7004. It is also broken in 1.0.14, 1.1.6, and 1.2.1. (These were the 'stable' releases at the time I reported this bug.) It is likely broken in older releases as well.
When saving to the database, Doctrine ignores the setting of PORTABILITY_EMPTY_TO_NULL. Currently, it will never change empty strings to NULL, no matter what the setting is for ATRR_PORTABILITY. This is because there is an error in the following 'if' statement:
Doctrine_Connection_Statement starting on line: 234
if ($this->_conn->getAttribute(Doctrine::PORTABILITY_EMPTY_TO_NULL)) { foreach ($params as $key => $value) { if ($value == '') { $params[$key] = null; } } }
the first test in this block should be (Portability Mode Attributes must be handled this way):
if ($this->_conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EMPTY_TO_NULL) {
the second test should be:
if (is_string($value) && $value === '')
In newer versions of php(not sure which), test for empty string must look like '===' not only '=='. It prevents integer and boolean value 0 to be handled as an empty string.
It's the same problem with.
$oDCon->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_RTRIM);
I think Doctrine::ATTR_ don't work.