HHH-14148 Fix ANTLR grammar non-determinism
This commit is contained in:
parent
886083ab77
commit
20e5a5659b
|
@ -146,7 +146,7 @@ selectStatement
|
||||||
from
|
from
|
||||||
( #(WHERE { out(" where "); } whereExpr ) )?
|
( #(WHERE { out(" where "); } whereExpr ) )?
|
||||||
( #(GROUP { out(" group by "); } groupExprs ( #(HAVING { out(" having "); } booleanExpr[false]) )? ) )?
|
( #(GROUP { out(" group by "); } groupExprs ( #(HAVING { out(" having "); } booleanExpr[false]) )? ) )?
|
||||||
( #(ORDER { out(" order by "); } orderBySqlFragmentOrExprs ) )?
|
( #(ORDER { out(" order by "); } orderExprs ) )?
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -191,18 +191,15 @@ whereClauseExpr
|
||||||
| booleanExpr[ false ]
|
| booleanExpr[ false ]
|
||||||
;
|
;
|
||||||
|
|
||||||
orderBySqlFragmentOrExprs
|
|
||||||
: sqlToken // for the purpose of mapping-defined orderBy SQL fragment
|
|
||||||
| orderExprs
|
|
||||||
;
|
|
||||||
|
|
||||||
orderExprs { String ordExp = null; String ordDir = null; String ordNul = null; }
|
orderExprs { String ordExp = null; String ordDir = null; String ordNul = null; }
|
||||||
// TODO: remove goofy space before the comma when we don't have to regression test anymore.
|
// TODO: remove goofy space before the comma when we don't have to regression test anymore.
|
||||||
// Dialect is provided a hook to render each ORDER BY element, so the expression is being captured instead of
|
// Dialect is provided a hook to render each ORDER BY element, so the expression is being captured instead of
|
||||||
// printing to the SQL output directly. See Dialect#renderOrderByElement(String, String, String, NullPrecedence).
|
// printing to the SQL output directly. See Dialect#renderOrderByElement(String, String, String, NullPrecedence).
|
||||||
: { captureExpressionStart(); } ( expr ) { captureExpressionFinish(); ordExp = resetCapture(); }
|
: { captureExpressionStart(); } ( e:expr ) { captureExpressionFinish(); ordExp = resetCapture(); }
|
||||||
(dir:orderDirection { ordDir = #dir.getText(); })? (ordNul=nullOrdering)?
|
(dir:orderDirection { ordDir = #dir.getText(); })? (ordNul=nullOrdering)?
|
||||||
{ out( renderOrderByElement( ordExp, ordDir, ordNul ) ); }
|
// SQL Tokens without a direction and null ordering can be passed through as-is.
|
||||||
|
// These tokens could be mapping defined order by fragments which are already rendered via the dialect hook
|
||||||
|
{ out( #e.getType() == SQL_TOKEN && ordDir == null && ordNul == null ? ordExp : renderOrderByElement( ordExp, ordDir, ordNul ) ); }
|
||||||
( {out(", "); } orderExprs )?
|
( {out(", "); } orderExprs )?
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue