Bug #87411
closedMultiple conditions for QueryBuilder leftJoin not possible
100%
Description
Hello Core-Team,
in case of joining f.e. sys_category I have to do generate following SQL
LEFT JOIN sys_category_record_mm
ON tx_events2_domain_model_event.uid = sys_category_record_mm.uid_foreign
AND sys_category_record_mm.tablenames = 'tx_events2_domain_model_event'
AND sys_category_record_mm.fieldname = 'categories'
I tried to solve it like described here:
https://stackoverflow.com/questions/15815869/doctrine2-left-join-with-2-conditions
$queryBuilder->leftJoin( 'e', 'sys_category_record_mm', 'cmm', $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'e.uid', $queryBuilder->quoteIdentifier('cmm.uid_foreign') ), $queryBuilder->expr()->eq( 'cmm.tablenames', $queryBuilder->createNamedParameter('tx_events2_domain_model_event', \PDO::PARAM_STR) ), $queryBuilder->expr()->eq( 'cmm.fieldname', $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR) ) ) );
But that results in an error message like "CompositeExpression given but string expected."
Right. You have strict typed 4th parameter in leftJoin:
public function leftJoin(string $fromAlias, string $join, string $alias, string $condition = null): QueryBuilder
Is it a problem to remove that strict type?
Stefan
Updated by Gerrit Code Review almost 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59412
Updated by Gerrit Code Review almost 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59412
Updated by Stefan Froemken almost 6 years ago
- Status changed from Under Review to Resolved
- Assignee set to Stefan Froemken
- % Done changed from 0 to 100
Ticket can be closed. Use getConcreteQueryBuilder()->leftJoin() or cast ExpressionBuilder to string.