Index: tests/Zend/Db/Table/TestCommon.php =================================================================== --- tests/Zend/Db/Table/TestCommon.php>-(revision 16264) +++ tests/Zend/Db/Table/TestCommon.php>-(working copy) @@ -643,6 +643,28 @@ $this->assertEquals(5, $lastInsertId); } - + /** + * @group ZF-2953 + */ + public function testTableInsertWithNoLengthPrimaryKeyField() + { + $table = $this->_table['bugs']; + $row = array ( + 'bug_id' => '', + 'bug_description' => 'New bug', + 'bug_status' => 'NEW', + 'created_on' => '2007-04-02', + 'updated_on' => '2007-04-02', + 'reported_by' => 'micky', + 'assigned_to' => 'goofy', + 'verified_by' => 'dduck' + ); + $insertResult = $table->insert($row); + $lastInsertId = $this->_db->lastInsertId(); + $this->assertEquals($insertResult, $lastInsertId); + $this->assertEquals(6, $lastInsertId); + } + public function testTableInsertWithSchema() { $schemaName = $this->_util->getSchema(); Index: library/Zend/Db/Table/Abstract.php =================================================================== --- library/Zend/Db/Table/Abstract.php>-(revision 16264) +++ library/Zend/Db/Table/Abstract.php>-(working copy) @@ -952,7 +952,7 @@ * If the primary key can be generated automatically, and no value was * specified in the user-supplied data, then omit it from the tuple. */ - if (array_key_exists($pkIdentity, $data) && $data[$pkIdentity] === null) { + if (array_key_exists($pkIdentity, $data) && strlen($data[$pkIdentity]) === 0) { unset($data[$pkIdentity]); } -