-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
Bug Report
| Q | A |
|---|---|
| BC Break | no |
| Version | v2.7.0 |
Summary
Ordering with arithmetic expression does not work as I'd expect it to work after reading the DQL EBNF.
Current behavior
This is a simplified example of the actual query.
SELECT
j,
(SELECT SUM(i.amount) FROM Invoice i WHERE i.job = j) AS HIDDEN invoiced_amount,
(SELECT COALESCE(SUM(t.orderedAmount), j.orderedAmount) FROM Task t WHERE t.job = j) AS HIDDEN current_ordered_amount
FROM Jobs j
ORDER BY current_ordered_amount - invoiced_amount ASC
Running the query, [Syntax Error] line 0, col xxx: Error: Expected end of string, got '-' is thrown.
How to reproduce
Run a query similar so the one above with an arithmetic expression in the ORDER BY clause.
Expected behavior
I'd expect the query to work because of what's stated in the documentation:
OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
OrderByItem ::= (SimpleArithmeticExpression | ...) ["ASC" | "DESC"]
SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}*
ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary
ArithmeticPrimary ::= ... | ResultVariable | ...
/* ResultVariable identifier usage of mapped field aliases (the "total" of "COUNT(*) AS total") */
ResultVariable = identifier
Is there something I missed? Or misinterpreted?