ZF-1862: Table unit test failing due to muliple SQL issued during call to insert()
testTableInsertWithSchema() is currently failing.
It calls insert() on a Table object:
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->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.