Querybuilder: Expected =, <, <=, <>, >, >=, !=, got 'IN' #7554

Open
opened 2026-01-22 15:53:23 +01:00 by admin · 1 comment
Owner

Originally created by @PaulCombal on GitHub (Sep 24, 2025).

Bug Report

Q A
Version 3.5.2

Summary

Using the querybuilder, using CASE WHEN + IN produces an error.
Using CASE WHEN with any other comparison works just fine

Current behavior

->andWhere("
CASE
  WHEN o.prop1 IS NOT NULL THEN o.propX
  WHEN o.prop2 IS NOT NULL THEN o.propY
  ELSE o.propZ
END IN (:values)
")

Produces:

[Syntax Error] line 0, col 911: Error: Expected =, <, <=, <>, >, >=, !=, got 'IN'

Indeed, using any of the listed operators work just fine.

I tried finding a workaround but didn't find any, all other alternative syntaxes produce the same issue.

Expected behavior

The above DQL works, as suggested by the SQL syntax.

How to reproduce

The first querybuilder works, where the second querybuilder doesn't:

        $this
            ->userRepository
            ->createQueryBuilder('u')
            ->andWhere('CASE WHEN u.email IS NULL THEN u.email ELSE u.email END = :value')
            ->setParameter('value', 'test')
            ->getQuery()
            ->getResult();

        $this
            ->userRepository
            ->createQueryBuilder('u')
            ->andWhere('CASE WHEN u.email IS NULL THEN u.email ELSE u.email END IN (:value)')
            ->setParameter('value', 'test')
            ->getQuery()
            ->getResult();

Thank you for the amazing work <3

Originally created by @PaulCombal on GitHub (Sep 24, 2025). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | ------ | Version | 3.5.2 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> Using the querybuilder, using CASE WHEN + IN produces an error. Using CASE WHEN with any other comparison works just fine #### Current behavior <!-- What is the current (buggy) behavior? --> ``` ->andWhere(" CASE WHEN o.prop1 IS NOT NULL THEN o.propX WHEN o.prop2 IS NOT NULL THEN o.propY ELSE o.propZ END IN (:values) ") ``` Produces: `[Syntax Error] line 0, col 911: Error: Expected =, <, <=, <>, >, >=, !=, got 'IN'` Indeed, using any of the listed operators work just fine. I tried finding a workaround but didn't find any, all other alternative syntaxes produce the same issue. #### Expected behavior <!-- What was the expected (correct) behavior? --> The above DQL works, as suggested by the SQL syntax. #### How to reproduce <!-- Provide a failing Unit or Functional Test - you can submit one in a Pull Request separately, referencing this bug report. And if you feel like it, why not fix the bug while you're at it? If that is too difficult, provide a link to a minimal repository containing an application that reproduces the bug. If the bug is simple, you may provide a code snippet instead, or even a list of steps. --> The first querybuilder works, where the second querybuilder doesn't: ``` $this ->userRepository ->createQueryBuilder('u') ->andWhere('CASE WHEN u.email IS NULL THEN u.email ELSE u.email END = :value') ->setParameter('value', 'test') ->getQuery() ->getResult(); $this ->userRepository ->createQueryBuilder('u') ->andWhere('CASE WHEN u.email IS NULL THEN u.email ELSE u.email END IN (:value)') ->setParameter('value', 'test') ->getQuery() ->getResult(); ``` Thank you for the amazing work <3
Author
Owner

@Dinesh0204 commented on GitHub (Oct 4, 2025):

Hi @PaulCombal ! I’ve opened a PR that addresses this issue: (https://github.com/doctrine/orm/issues/12178).
It includes a test and fixes the parser problem.

@Dinesh0204 commented on GitHub (Oct 4, 2025): Hi @PaulCombal ! I’ve opened a PR that addresses this issue: (https://github.com/doctrine/orm/issues/12178). It includes a test and fixes the parser problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7554