ZF-1862: Table unit test failing due to muliple SQL issued during call to insert()
Description
testTableInsertWithSchema() is currently failing.
It calls insert() on a Table object:
$table->insert();
Under the covers, the DB2 adapter makes 2 SQL calls: An SQL INSERT and an SQL SELECT. The SELECT is to obtain the last insert id.
The unit test uses the Profiler to determine what the last SQL statement issued looks like assuming only the INSERT statement was executed.
In the case of DB2, because the last statement issued was a SELECT, the assert comparison fails.
The solution is to obtain the first query profile, not the last one from the profiler:
$qp = $this->_db->getProfiler()->getQueryProfiles();
$tableSpec = $this->_db->quoteIdentifier($schemaName.'.'.$tableName, true);
$this->assertContains("INSERT INTO $tableSpec ", $qp[0]->getQuery());
Another option is to filter query profiles in the parent TestCommon.php class using Zend_Db_Profiler, but filtering is currently not working. Please see http://framework.zend.com/issues/browse/ZF-1861
A patch for DB2Test.php will be attached.
Comments
Posted by Salvador Ledezma (ledezma) on 2007-08-17T20:23:38.000+0000
Patch to fix failing unit test
Posted by Bill Karwin (bkarwin) on 2007-08-18T17:48:58.000+0000
Assigning to Bill Karwin
Posted by Salvador Ledezma (ledezma) on 2007-08-21T17:39:07.000+0000
Added some detail to the summary
Posted by Darby Felton (darby) on 2007-11-13T12:54:43.000+0000
Assigning to [~ledezma]
Posted by Thomas Weidner (thomas) on 2008-03-12T14:43:06.000+0000
Hy Salvador,
if you are not able to commit then you should un-assign this issue, so another person with commit-rights can do this.
Otherwise you should commit your changes and close this issue. ;-)
Posted by Wil Sinclair (wil) on 2008-03-25T22:02:48.000+0000
Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.
Posted by Mickael Perraud (mikaelkael) on 2009-11-20T12:45:15.000+0000
Fixed with r19140