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[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

A patch for DB2Test.php will be attached.


Patch to fix failing unit test

Assigning to Bill Karwin

Added some detail to the summary

Assigning to [~ledezma]

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. ;-)

Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.

Fixed with r19140