JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
Trying to parse an ALTER TABLE statement for MySQL fails when the column definition contains the CHARACTER SET keywords.
Encountering the following error
ParseException: Encountered unexpected token: "SET" "SET"
at line 2, column 55.
Was expecting one of:
","
<EOF>
<ST_SEMICOLON>
SQL Example:
ALTER TABLE `foo_bar`
ADD COLUMN `baz` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
ALGORITHM = INSTANT;
Software Information:
JSqlParser version: 5.0
Database MySQL
Writing in Scala, though that shouldn't affect anything 🤞
Additional information
The failing code is
CCJSqlParserUtil.parseStatements(fileContent)
where fileContent is a String containing the entire content of the SQL file.
Failing SQL Feature:
Trying to parse an
ALTER TABLE
statement for MySQL fails when the column definition contains theCHARACTER SET
keywords. Encountering the following errorSQL Example:
Software Information:
Additional information
The failing code is
where
fileContent
is aString
containing the entire content of the SQL file.