Skip to content

Fixes error on complex where statements#206

Closed
Stumpftopf wants to merge 1 commit intoKnpLabs:masterfrom
Stumpftopf:master
Closed

Fixes error on complex where statements#206
Stumpftopf wants to merge 1 commit intoKnpLabs:masterfrom
Stumpftopf:master

Conversation

@Stumpftopf
Copy link

Fixes #205

@nicolasmure
Copy link
Contributor

Hello @Stumpftopf ,

Thank you for your contribution, do you mind to write a test covering this fix ?

@markus-fischbacher
Copy link

Any chance to get that merged in time?
I have the same problem.

@garak
Copy link
Collaborator

garak commented Sep 2, 2019

We can't merge it without tests

@markus-fischbacher
Copy link

@garak Thanks for the clearification. I‘ll fork the repo temporarly.

Copy link
Collaborator

@garak garak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

@MisatoTremor
Copy link
Contributor

This fix is also missing the case that $node->conditionalExpression can be another ConditionalPrimary.

An example where this happens is for

$expr->orX(
    $expr->between('event_date.dateFrom', ':start', ':end'),
    $expr->between('event_date.dateTo', ':start', ':end')
)

that since doctrine/orm@550fcbc#diff-77ad6f787b65be81710fe85fee3d41f4b8e0b766446f8f24c28e0440b7eea17eR61 results in ((event_date.dateFrom BETWEEN :start AND :end) OR (event_date.dateTo BETWEEN :start AND :end)).
Also true for other instances of unnecessary parenthesis (which are still valid DQL, though).

@netfeld
Copy link

netfeld commented Mar 22, 2023

I get a bug when i use the default search with a simple query together with andWhere

$qb = $em->createQueryBuilder()
            ->select('u')
            ->from('App:Participant','u')
            ->where('u.registration=:registration')->setParameter('registration',$registration->getId())
            ->andWhere('(u.isWaiting=0 or u.isWaiting is null)')
        ;

This patch works like a charm! Please merge!!

@garak
Copy link
Collaborator

garak commented Mar 22, 2023

This patch works like a charm! Please merge!!

As soon as we have some automatic tests to confirm that it works, I'll be glad to merge.

@czachor
Copy link

czachor commented Dec 3, 2024

Same here:

$qb = 
        $this->createQueryBuilder('u')
            ->select('u, stt')
            ->leftJoin('u.parents', 'up')
            ->leftJoin('u.teachers', 'stt')
            ->leftJoin('stt.supportingTeachers', 'st')
            ->andWhere(
                    // When first line below is removed, error is gone.
                   '(stt.teacher = :teacher OR st.id = :teacher) AND 
                    stt IS NOT NULL')
            ->setParameter('teacher', $teacher);

@shakaran
Copy link
Contributor

I just create #349 with the tests in case that you want superseed this PR. Thanks

@garak garak closed this Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error while filtering

8 participants