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

Extra parentheses causing DQL errors? #11784

Open
mpdude opened this issue Jan 7, 2025 · 0 comments
Open

Extra parentheses causing DQL errors? #11784

mpdude opened this issue Jan 7, 2025 · 0 comments

Comments

@mpdude
Copy link
Contributor

mpdude commented Jan 7, 2025

Q A
Version 2.19.5

I noticed today that in some places, the DQL parser can be picky about extra parentheses used around expressions.

For example, the following is a working query:

SELECT CONCAT(CASE s.id WHEN 1 THEN 'foo' WHEN 2 THEN 'bar' ELSE 'baz' END, 'suffix') FROM Something s

... but adding extra parentheses around the case expression (for better readability) makes it invalid:

SELECT CONCAT((CASE s.id WHEN 1 THEN 'foo' WHEN 2 THEN 'bar' ELSE 'baz' END), 'suffix') FROM Something s

[Syntax Error] line 0, col 14: Error: Expected StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression, got '('

This led me to believe that maybe I should be careful about parentheses in general, but both of the following are OK:

SELECT 'bar' FROM Something s
SELECT ('bar') FROM Something s

... but not e. g. within a CONCAT expression:

SELECT CONCAT('foo', ('bar')) FROM Something s (fails)

All corresponding constructs are valid in SQL, and I always just assumed (without thinking deeper about it) that extra parentheses should not pose a problem.

Did I miss something, or is this just a glitch in the grammar/parser 🤪?

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