You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing SQL Feature:
Brief description of the failing SQL feature
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>
at line 1, column 39.
SQL Example:
Simplified Query Example, focusing on the failing feature
UPDATE shop_info SET title=?,
props=? WHERE id=?
This SQL statement is dynamically concatenated in the program using a third-party library, so it is not possible to remove the extra blank lines within it. Even with the extra blank lines, it can be executed normally in MySQL, which means it does not have syntax errors.
Software Information:
JSqlParser version 4.6
Database MySQL
Tips:
Please write in English and avoid Screenshots (as we can't copy and paste content from it). Try your example online with the latest JSQLParser and share the link in the error report.
Do provide Links or References to the specific Grammar and Syntax you are trying to use.
Two empty lines \n\n\n terminate a statement. There is no good reason for a statement to contain more than 1 empty line, but there are many good reasons to split statements at empty lines when you don't want to write semicolons.
If you still insist on empty lines then just use something like String.replaceAll("\n\n+", "\n").
With JSQLParser 4.10 Snapshot, you can use the method CCJSqlParserUtil.sanitizeSingleSql( sqlStr) to sanitize your statement. It will remove the redundant empty lines using a regular expression which honors StringLiteral.
changed the title [-][BUG] JSQLParser Version : 4.6 : Encountered unexpected token: "\n\n\n" <ST_SEMICOLON> at line 1, column 39.[/-][+]Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>[/+]on May 1, 2024
Activity
manticore-projects commentedon Apr 9, 2024
Greetings!
Two empty lines
\n\n\nterminate a statement. There is no good reason for a statement to contain more than 1 empty line, but there are many good reasons to split statements at empty lines when you don't want to write semicolons.If you still insist on empty lines then just use something like
String.replaceAll("\n\n+", "\n").pansong291 commentedon Apr 10, 2024
@manticore-projects Hello, I don't think it's that simple. Consider the following SQL statement, it cannot simply replace empty lines:
manticore-projects commentedon Apr 18, 2024
With JSQLParser 4.10 Snapshot, you can use the method
CCJSqlParserUtil.sanitizeSingleSql( sqlStr)to sanitize your statement. It will remove the redundant empty lines using a regular expression which honorsStringLiteral.[-][BUG] JSQLParser Version : 4.6 : Encountered unexpected token: "\n\n\n" <ST_SEMICOLON> at line 1, column 39.[/-][+]Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>[/+]