Like expression with case statement error #7471

Open
opened 2026-01-22 15:52:06 +01:00 by admin · 0 comments
Owner

Originally created by @cbichis on GitHub (Feb 4, 2025).

Hello,
Its seems a QueryBuilder CASE statement combined with a LIKE is throwing this error:

Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE'

A similar issue was reported some time ago but only on "Discussions" part of the site, i'll paste here the DQL:

SELECT u, CASE WHEN u.roles LIKE '%ROLE_SUPER_ADMIN%' THEN 'Admin' ELSE '' END AS role
FROM App\Entity\User u
WHERE (CASE WHEN u.roles LIKE '%ROLE_SUPER_ADMIN%' THEN 'Admin' ELSE '' END LIKE :filter0_0)

and I got the error [Syntax Error] line 0, col 936: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE'

Originally created by @cbichis on GitHub (Feb 4, 2025). Hello, Its seems a QueryBuilder CASE statement combined with a LIKE is throwing this error: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE' A similar issue was reported some time ago but only on "Discussions" part of the site, i'll paste here the DQL: SELECT u, CASE WHEN u.roles LIKE '%ROLE_SUPER_ADMIN%' THEN 'Admin' ELSE '' END AS role FROM App\Entity\User u WHERE (CASE WHEN u.roles LIKE '%ROLE_SUPER_ADMIN%' THEN 'Admin' ELSE '' END LIKE :filter0_0) and I got the error [Syntax Error] line 0, col 936: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE'
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7471