Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleConditionalExpressions can not parse CASE ... BETWEEN #11735

Open
hubipe opened this issue Nov 27, 2024 · 0 comments
Open

SimpleConditionalExpressions can not parse CASE ... BETWEEN #11735

hubipe opened this issue Nov 27, 2024 · 0 comments

Comments

@hubipe
Copy link

hubipe commented Nov 27, 2024

Bug Report

Parser can not parse this DQL:

SELECT o.id
FROM Entity o
WHERE CASE o.vatIncluded WHEN TRUE THEN o.priceVat ELSE o.priceWoVat END BETWEEN 100 AND 300

The exception Expected =, <, <=, <>, >, >=, !=, got 'BETWEEN' is raised instead of successful parsing.
The only way around I found about it was to wrap the CASE to a function:

SELECT o.id
FROM Entity o
WHERE ABS(CASE o.vatIncluded WHEN TRUE THEN o.priceVat ELSE o.priceWoVat END) BETWEEN 100 AND 300

In this case, the query is parsed successfully.
It is worth noting, that adding parentheses anywhere won't help.

Q A
Version 2.19.6 and 2.5.14

Current behavior

Parser raises exception

Expected behavior

Parser should parse the query successfully

How to reproduce

Run this in PHP:

$em->createQuery('SELECT o.id
FROM Entity o
WHERE CASE o.vatIncluded WHEN TRUE THEN o.priceVat ELSE o.priceWoVat END BETWEEN 100 AND 300')->getAST();

You'll get an exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant