Task #105387
closedAdd an exception for update or delete with join and queryBuilder
100%
Description
With queryBuilder, you can make a delete or update query with a join condition like this:
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
$queryBuilder
->update('tt_content')
->leftJoin('tt_content', 'sys_file_reference')
->where(
$queryBuilder->expr()->eq('tt_content.bodytext', $queryBuilder->createNamedParameter('lorem', Connection::PARAM_STR)),
$queryBuilder->expr()->eq('sys_file_reference.fieldname', $queryBuilder->createNamedParameter('assets', Connection::PARAM_STR)),
)
->set('tt_content.bodytext', 'dolor')
->executeStatement();
but join condition are not supported by doctrine/dbal because the join method is not supported in all db engines for delete or update.
And with queryBuilder this result in an SQL error like:
(1/3) #1054 Doctrine\DBAL\Exception\InvalidFieldNameException
An exception occurred while executing a query: Unknown column 'sys_file_reference.fieldname' in 'where clause'
which is not very clear.
I suggest to add an exception in queryBuilder when you try to add a join for an update or a delete.
Updated by Gerrit Code Review 29 days ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 29 days ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 29 days ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 29 days ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Stefan Bürk 29 days ago
- Related to Task #105861: Avoid invalid reuse of QueryBuilder in Typo3DatabaseBackend added
Updated by Gerrit Code Review 29 days ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 29 days ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 24 days ago
Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 24 days ago
Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 19 days ago
Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 19 days ago
Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Gerrit Code Review 19 days ago
Patch set 11 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87585
Updated by Stefan Bürk 19 days ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 0913a3db858ed26bcfcc4a06659c1e2cd8d122c8.