zendframework/zend-db

Fixed bug in comparison at AbstractTableGateway->executeInsert

Opened this issue · 2 comments

GeeH commented

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7217
User: @edsonhoraciojunior
Created On: 2015-02-13T20:13:11Z
Updated At: 2015-02-19T21:29:24Z
Body
When executeInsert is called, sometimes $insertState['table'] is string or Zend\Db\Sql\TableIdentifier, that also happens with $this->table.

I got to a case that $insertState['table'] is string and $this->table is Zend\Db\Sql\TableIdentifier and that isn't mapped so a Exception is always thrown.

Example:

$tableGateway = new \Zend\Db\TableGateway\TableGateway('table1', $dbAdapter);
$sql = new \Zend\Db\Sql\Sql($dbAdapter);

// Prepare a insert with select
$select = $sql->select('any_table');
$select->columns(array('column1', 'column2'));
$select->where('status' => 'active');

$insert = $sql->insert('table1');
$insert->columns(array('column1', 'column2'));
$insert->values($select); //could be $insert->select($select) too

$tableGateway->insertWith($insert); // this will call AbstractTableGateway->executeInsert


Comment

User: @sasezaki
Created On: 2015-02-14T06:36:59Z
Updated At: 2015-02-14T06:36:59Z
Body
@edsonhoraciojunior Could you add unit-test ?


Comment

User: @weierophinney
Created On: 2015-02-19T21:29:24Z
Updated At: 2015-02-19T21:29:24Z
Body
I'd like to schedule this for 2.4, but I need a test case, @edsonhoraciojunior


This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#110.