-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
The :: syntax is a shorthand for CAST
A valid Postgresql expression such as
('x'||substr(md5(hostname),1,16))::bit(64)::bigint as id_,
results in a parse error.
The problem is that in JSqlParserCC.jjt, the repetition block for :: specifies zero or 1 occurrences
(that is, enclosed in square braces [ ... ])
The fix is to specify zero or more occurrences.
at line 2505 or so in JSqlParserCC.jjt, change the code from
[ "::" type=ColDataType() {
castExpr = new CastExpression();
castExpr.setUseCastKeyword(false);
castExpr.setLeftExpression(retval);
castExpr.setType(type);
retval=castExpr;
} ]
to
( "::" type=ColDataType() {
castExpr = new CastExpression();
castExpr.setUseCastKeyword(false);
castExpr.setLeftExpression(retval);
castExpr.setType(type);
retval=castExpr;
} )*
I rebuilt JSqlParser using
mvn package
and the revised code passes all tests.
The revised code parsers the statement, and the default SQL generator returns the :: sequence.