You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hats off:
If I want to use the g4 file provided with the library and follow the documentation generated for the Go language to complete the extraction of SQL fingerprints using go-antlr4 which of the many generated listener implementation functions should I start with.
Example:
SELECT * FROM helloworld WHERE username = '1_32-32' AND number >= -3+4-0 AND number2 <= -8 AND expression_3414123 LIKE '%_43421'
I expect to get
template := SELECT * FROM helloworld WHERE username = ? AND number >= ? AND number2 <= ? AND expression_3414123 LIKE ?
Parameters: ['1_32-32', -3+4-0, -8, '%_43421']
Includes other syntax
The text was updated successfully, but these errors were encountered:
After choosing a grammar, parse the input, and print the parse tree. From that, you can get an idea of what you need to write in an Antlr Listener.
Also, I don't know about the Antlr Listener pattern in Go, but I raised the of Antlr Visitor patterns do not work for Go as one would expect coming from any of the other targets. antlr/antlr4#4398. The problem is that Go is not object-oriented, which means that you have to implement every visitor ParserRuleContext node "method". I do not remember if it works as expected for Listeners.
Thank you for your answer.
Prior to this I have completed the way you described above by analyzing it and also printing the entire syntax tree structure, and in the generated code there is only the default empty implementation of the listener.
I understand that it is necessary to go for the implementation of the adoptable listener approach, and by checking the relevant information, similar to tidb's sqlparser library, it seems that there is no visitor interface.
Going back to the original question, my goal is to implement most of the SQL under grammars-v4, not limited to mysql, plsql, postgresql.
Hats off:
If I want to use the g4 file provided with the library and follow the documentation generated for the Go language to complete the extraction of SQL fingerprints using go-antlr4 which of the many generated listener implementation functions should I start with.
Example:
SELECT * FROM helloworld WHERE username = '1_32-32' AND number >= -3+4-0 AND number2 <= -8 AND expression_3414123 LIKE '%_43421'
I expect to get
template := SELECT * FROM helloworld WHERE username = ? AND number >= ? AND number2 <= ? AND expression_3414123 LIKE ?
Parameters: ['1_32-32', -3+4-0, -8, '%_43421']
Includes other syntax
The text was updated successfully, but these errors were encountered: