ZF-2450: New rows created with createRow() contain all null fields

Description

When news rows are created with createRow(), all of the row's fields are set to null. This causes problems when attempting to save the row to the database using save() if the table does not allow null fields. An exception is thrown when using the MySQLi adapter.

If possible, createRow() should set all of its fields to the field's default value according to the meta data in order to be consistent with the database's normal operation of the simple insert query.

Alternatively, createRow() could return a row with no fields at all (or set to an internal "not set" value), thus allowing save() to determine which fields have been set before using save(), and only use those fields when constructing the INSERT statement. The resulting SQL would then be the simplest insert possible, and allow SQL to handle missing fields appropriately.


INSERT INTO `table` SET `id` = NULL

The PHP code to reproduce the same insert should be:


$row = $table->createRow();
$row->save();

The current alternative for saving new rows to a table is to use insert(), which works properly when fields are omitted.

Comments

We already have a way of tracking 'clean'/'dirty' data so this won't be hard to achieve. Will book it in ASAP.

Resolved in trunk r8110