Details
Description
DQL queries like:
SELECT - someEntity.someNumericField FROM \SomeEntity someEntity
will result in a syntax error:
[Syntax Error] line 0, col 7: Error: Expected IdentificationVariable | StateFieldPathExpression | AggregateExpression | "(" Subselect ")" | ScalarExpression, got '-''
I think this should work, because the relevant EBNF definitions state the following:
SimpleSelectExpression ::= ScalarExpression | IdentificationVariable |
(AggregateExpression [["AS"] AliasResultVariable])
ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression
BooleanPrimary | EntityTypeExpression | CaseExpression
SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}*
ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary
ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")"
| FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings
| FunctionsReturningDatetime | IdentificationVariable | InputParameter | CaseExpression
SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression
StateFieldPathExpression ::= IdentificationVariable "." StateField | SingleValuedAssociationPathExpression "." StateField
Therefore, the expression "- someEntity.someField" is a legitimate arithmetic factor, which ultimately should be a legitimate scalar expression too, which is a legitimate simple select expression.
Fortunately, this is easy to work around, by simply subtracting from zero, like in:
SELECT 0 - someEntity.someNumericField FROM \SomeEntity someEntity
Fixed.