Skip to content

4.1 Parser fails on Nested Comments /* foo /*bar*/ */ #1175

@manticore-projects

Description

@manticore-projects

JSQLParser 4.1:

-- Nested Comments failure
select /*this is a /*nested!!!*/ comment*/ 1
from dual;

at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:206)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:194)

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:28225)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:28064)
at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:623)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:204)

This is ugly, but valid SQL for H2 and Oracle so maybe we will want to support nested comments eventually.

I see 2 options:

  1. fix the parser itself
  2. or stripping any comments from the SQL before handing it over to the parser (per Regular Expressions)

Please let me know which way you'd prefer and I would have a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions