Task #243 — null fields are not inserted as NULL in the database
Attached to Project— EZPDO
Opened by Joao Fonseca (joao_fonseca) - Wednesday, 30 Jan 2008, 7:19am
| Bug Report | |
| Runtime API | |
| Unconfirmed | |
| No-one | |
| All |
| High | |
| Normal | |
| CVS | |
| Undecided | |
|
When an object is saved to the database, the fields with null values are not persisted with the corresponding NULL database value (numbers are set to 0, and strings to "") The problem is located in "db/epDbObject.php". Functions that save objects to the database are not testing for null fields. |
This task depends upon
This task blocks these from closing
Comments (1) | Attachments (0) | Related Tasks (0/0) | Notifications (1) | Reminders (0) | History |
Comment by Joao Fonseca - Wednesday, 30 Jan 2008, 7:52am
A starting point to fix this bug is the following modification to db/epDbObject.php:
public function quote($v, $fm = null) {
if ( is_null( $v ) ) {
$default = is_null( $fm ) ? null : $fm->getDefaultValue();
return is_null( $default ) ? 'NULL' : $this->quote( $default, $fm );
}
and
protected function _castType(&$val, $ftype) {
if ( is_null( $val ) )
return null;