zendframework / zend-db

Db component from Zend Framework
BSD 3-Clause "New" or "Revised" License
101 stars 122 forks source link

Fixed bug in comparison at AbstractTableGateway->executeInsert #138

Open GeeH opened 8 years ago

GeeH commented 8 years ago

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


froschdesign commented 8 years ago

Ping @edsonhoraciojunior

michalbundyra commented 4 years ago

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/110.