Project

General

Profile

Actions

Task #105387

closed

Add an exception for update or delete with join and queryBuilder

Added by Florian Rival 3 months ago. Updated 19 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2024-10-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.2
Tags:
Complexity:
easy
Sprint Focus:

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.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #105861: Avoid invalid reuse of QueryBuilder in Typo3DatabaseBackendResolvedStefan Bürk2024-12-23

Actions
Actions #1

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

Actions #2

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

Actions #3

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

Actions #4

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

Actions #5

Updated by Stefan Bürk 29 days ago

  • Related to Task #105861: Avoid invalid reuse of QueryBuilder in Typo3DatabaseBackend added
Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

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

Actions #10

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

Actions #11

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

Actions #12

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

Actions #13

Updated by Stefan Bürk 19 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF