Replies: 1 comment 4 replies
-
Interesting use case. I guess we need a new starting grammar rule for this. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have observed that JsqlParser throws an error when trying to parse an empty query. For example, the following queries all throw an error:
CCJSqlParserUtil.parse("");
CCJSqlParserUtil.parse(" ");
CCJSqlParserUtil.parse(" -- some comment\n /* other comment */ ");
The error thrown is ambiguous, and is either "Encountered unexpected token:" or "Array index out of range: -1".
For my use case, users enter an SQL string into a text field, and JsqlParser is used to parse the string. I would like to specifically determine the case where the string is empty and/or only comments. Checking for empty or whitespace only strings is easy to do outside of JsqlParser. But, it is not straightforward to determine if the string is empty once filtering out comments. Is there any way to determine this with JsqlParser?
Beta Was this translation helpful? Give feedback.
All reactions