JSQLParser / JSqlParser

JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
https://github.com/JSQLParser/JSqlParser/wiki
Apache License 2.0
5.29k stars 1.34k forks source link

[BUG] Compilation error after execution of updateKeywords #2040

Closed ssteinhauser closed 1 month ago

ssteinhauser commented 1 month ago

The execution of the updateKeywords task adds the following tokens to RelObjectNameWithoutValue:

https://github.com/JSQLParser/JSqlParser/blob/411a3da9facf20634c619eb6ffb5626ea57ce7d1/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt#L529-L551

This causes the javacc-jjtree goal to fail:

Error: Line 1962, Column 313: String token "BISTRING" has been defined as a private regular expression.
Error: Line 1962, Column 1163: String token "ENUM" has been defined as a private regular expression.
Error: Line 1962, Column 1500: String token "HUGEINT" has been defined as a private regular expression.
Error: Line 1962, Column 1815: String token "MAP" has been defined as a private regular expression.
Error: Line 1962, Column 3401: String token "TIMETZ" has been defined as a private regular expression.
Error: Line 1962, Column 3527: String token "UBIGINT" has been defined as a private regular expression.
Error: Line 1962, Column 3542: String token "UHUGEINT" has been defined as a private regular expression.
Error: Line 1962, Column 3558: String token "UINTEGER" has been defined as a private regular expression.
Error: Line 1962, Column 3672: String token "USMALLINT" has been defined as a private regular expression.
Error: Line 1962, Column 3689: String token "UTINYINT" has been defined as a private regular expression.
Error: Line 1962, Column 3705: String token "UUID" has been defined as a private regular expression.
manticore-projects commented 1 month ago

Thank you for reporting, I actually broke it myself when introducing complex compound Data Type tokens. I will definitely fix it, but this will take a couple of days since I am in transit right now. Sorry for any inconvenience.

ssteinhauser commented 1 month ago

Thank you for the quick reply. I tried to implement and provide a solution. The idea is to parse and iterate over each token definition and don't whitelist anything which is defined within a private token. Let me know your thoughts on this: #2044

However, there is still an issue, related to #2041. After running the updateKeywords now, PRECISION and BASE64 will be removed. PRECISION is removed, because it is just part of a private token. BASE64 is removed, because numbers in the token values are not being whitelisted due to the condition tokenValue.matches("[A-Za-z]+").