You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 🤪?
The text was updated successfully, but these errors were encountered:
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 🤪?
The text was updated successfully, but these errors were encountered: