Project

General

Profile

Actions

Bug #87411

closed

Multiple conditions for QueryBuilder leftJoin not possible

Added by Stefan Froemken almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2019-01-11
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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

Actions #1

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

Actions #2

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

Actions #3

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.

Actions #4

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF