Issues

ZF-1862: Table unit test failing due to muliple SQL issued during call to insert()

Issue Type: Unit Tests: Improvement Created: 2007-08-17T20:20:44.000+0000 Last Updated: 2009-11-20T12:45:15.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Salvador Ledezma (ledezma) Assignee: Mickael Perraud (mikaelkael) Tags: - Zend_Db_Adapter_Db2

Related issues: - ZF-3072

Attachments: - Db2Test.php

Description

testTableInsertWithSchema() is currently failing.

It calls insert() on a Table object:

<pre class="highlight">
$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:

<pre class="highlight">
        $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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts