This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
Using TableGateway::insert() fails when table has an alias #7311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to use a single table
Users
via TableGateway. I need to put an alias on a table to be able to use it inselect
query. I'm using a PDO driver with MySQL platform.When you create a new TableGateway:
you can use this instance to
select
whatever you like. However, when you try toinsert
anything using that instance,Zend\Db\Sql\Insert
tries to quote table identifier (using adapter's platform) and it fails onas
$identifier
is an array ofarray('U' => 'Users')
in that case.I understand there are no table aliases in SQL insert of any flavour, still, I believe this is a bug as
Zend\Db\Sql\Insert
is missing something similar to whatZend\Db\Sql\Select
does:Also, it happens with
TableIdentifier
as well if you add table with alias to it. AsTableGateway
honours table notation with alias, I'd expect to still be able to do any CRUD actions on it.