Community
Participate
Working Groups
The parser org.eclipse.datatools.sqltools.parsers.sql.query throws an NPE when parsing SQL with "--" end-of-line style comments. This was found using the interactiveTest: Plugin: org.eclipse.datatools.sqltools.parsers.sql.query.test Program: InteractiveTest This is run as a "Java Application". The SQL I tried was: SELECT DISTINCT PAYMENTNO, PLAYERNO -- comment FROM DBA.PENALTIES; and the console contains this error: Parsing: SELECT DISTINCT PAYMENTNO, PLAYERNO -- comment FROM DBA.PENALTIES; Error reading from stdin, quitting...null org.eclipse.datatools.sqltools.parsers.sql.SQLParserInternalException at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.makeAST(SQLParserManager.java:528) at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.parse(SQLParserManager.java:791) at org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager.parseQuery(SQLQueryParserManager.java:326) at org.eclipse.datatools.sqltools.parsers.sql.query.test.InteractiveTest.main(InteractiveTest.java:78) Caused by: java.lang.NullPointerException at lpg.lpgjavaruntime.AbstractToken.getValue(AbstractToken.java:53) at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.createCommentObject(AbstractSQLQueryParser.java:528) at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.createCommentObjectsSorted(AbstractSQLQueryParser.java:477) at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.addCommentsToAST(AbstractSQLQueryParser.java:117) at org.eclipse.datatools.sqltools.parsers.sql.AbstractSQLParser.parser(AbstractSQLParser.java:391) at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.makeAST(SQLParserManager.java:436) ... 3 more
Created attachment 88356 [details] Part 1 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88357 [details] Part 2 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88358 [details] Part 3 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88359 [details] Part 4 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88360 [details] Part 5 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88361 [details] Part 6 of patch for o.e.d.modelbase.sql.query plugin
Created attachment 88362 [details] Patch for o.e.d.modelbase.sql.query.edit plugin
Created attachment 88363 [details] Patch for o.e.d.sqltools.parsers.sql plugin
Created attachment 88364 [details] Patch for o.e.d.sqltools.parsers.sql.lexer plugin
Created attachment 88365 [details] Patch for o.e.d.sqltools.parsers.sql.query plugin
These patches to the modelbase.sql.query plugins and the sqltools.parsers.sql plugins fix several problems, including comment handling. The patch for the modelbase.sql.query plugin is very large because the EMF code generator changed almost all the methods in all the model classes in some trivial way. The number of real changes in plugin is actually quite small.
Should be working now. Let me know if not.
The NPE is fixed. I was expecting comment objects to be added to the AST when the query contained comments, but there's nothing in the AST representing the comment using the test described above.
Closing...