Project

General

Profile

Actions

Bug #102708

closed

Let queryBuilder support compositeExpression as joinCondition

Added by Harald Witt 5 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-12-21
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
queryBuilder CompositExpression Join
Complexity:
Is Regression:
Sprint Focus:

Description

$queryBuilder->leftJoin and other joins does not support TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression as joinCondition. Doing this will result in a 503.
That is really a bug or at least a missing feature, because e. g. mm_matchFields MUST be compared in the joinCondition and NOT in the where-clause. Why? Here is the reason ...

Using a CompositeExpression with mm_matchFields as joinCondition:
A primary record with no partner record in the secondary table is joined with a bunch of NULL fields and is INCLUDED in the result of the join. So a where-clause, reflecting a condition of the primary table COULD MATCH.

Using mm_matchFields in where conditions:
A primary record with no partner record in the secondary table is EXCLUDED from the join result. So a where-clause, reflecting a condition of the primary table will NEVER MATCH.

That's the same problem already solved here for the TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser:
See https://forge.typo3.org/issues/93337#change-493419

$joinConditionExpression = $this->queryBuilder->expr()->and(
    $basicJoinCondition,
    $this->getAdditionalMatchFieldsStatement($this->queryBuilder->expr(), $columnMap, $childTableAlias, $realTableName)
);

Code example follows ...

Actions

Also available in: Atom PDF