TZTokenizer fails to detect -- comments
Posted: 10.01.2022, 21:44
Hello,
In my application I needed to distinguish if a query returns a resultset or not so I wrote a string parser to look for the first valid keyword of a text. For a while I migrated this logic to use TZTokenizer instead and now I found out that the following query:
is actually considered one WITHOUT a resultset, as TZTokenizer finds "This" as the first word token.
works fine. Which is actually a bug as "-" is declared as a possible comment token, see ZGenericSQLToken.pas : 531 (TZGenericSQLTokenizer.CreateTokenStates):
I sent a pull request on GitHub with the possible fix, however I'm unsure if this is the correct way to do this. Take it with a grain of salt, please :)
In my application I needed to distinguish if a query returns a resultset or not so I wrote a string parser to look for the first valid keyword of a text. For a while I migrated this logic to use TZTokenizer instead and now I found out that the following query:
Code: Select all
-- This is a comment
SELECT * FROM MyTabe
Code: Select all
/* This is a comment */
SELECT * FROM MyTable
Code: Select all
SetCharacterState('-', '-', CommentState);