Project

General

Profile

Actions

Feature #87776

closed

Limit Restriction to table/s in QueryBuilder

Added by Manuel Selbach about 5 years ago. Updated almost 4 years ago.

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

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

With the concept to apply restrictions to the query it is not possible to decide for which table it should be used.
In some cases it is needed to apply restriction only to a certain table.

Example:

$queryBuilder->getRestrictions()
    ->removeAll()
    ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
    ->add(GeneralUtility::makeInstance(HiddenRestriction::class));
$queryBuilder->select('s.uid', 's.pid', 's.hidden', 's.title', 's.flag')
    ->from('sys_language', 's')
    ->from('pages_language_overlay', 'o')
     ->where(
        $queryBuilder->expr()->eq('o.sys_language_uid', $queryBuilder->quoteIdentifier('s.uid')),
        $queryBuilder->expr()->eq('o.pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
    );

In this example the HiddenRestriction should only be applied to "sys_language", but will be applied to both tables currently.

So it should be possible to limit the restriction like:

$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(HiddenRestriction::class, ['sys_language']))

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #88919: QueryBuilder with DefaultRestrictionContainer effectivly transforms outer joins to inner joins because the restrictions are applied to all join tables unconditionallyClosed2019-08-05

Actions
Actions

Also available in: Atom PDF