Zend Framework

Table unit test failing due to muliple SQL issued during call to insert()

Details

  • Type: Unit Tests: Improvement Unit Tests: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Db_Adapter_Db2
  • Labels:
    None
  • Fix Version Priority:
    Should Have

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.

Issue Links

Activity

Hide
Salvador Ledezma added a comment -

Patch to fix failing unit test

Show
Salvador Ledezma added a comment - Patch to fix failing unit test
Hide
Bill Karwin added a comment -

Assigning to Bill Karwin

Show
Bill Karwin added a comment - Assigning to Bill Karwin
Hide
Salvador Ledezma added a comment -

Added some detail to the summary

Show
Salvador Ledezma added a comment - Added some detail to the summary
Hide
Darby Felton added a comment -

Assigning to Salvador Ledezma

Show
Darby Felton added a comment - Assigning to Salvador Ledezma
Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.
Hide
Mickael Perraud added a comment -

Fixed with r19140

Show
Mickael Perraud added a comment - Fixed with r19140

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1d
Original Estimate - 1 day
Remaining:
1d
Remaining Estimate - 1 day
Logged:
Not Specified
Time Spent - Not Specified