Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse SQL statement types with node-sql-parser instead of rely on the first token. #14

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

jurgenmahn
Copy link

server used to rely on the first token of the SQL query (e.g., “SELECT”, “UPDATE”) to decide whether it was a read or write query. This was prone to errors when queries started with non-standard tokens or subqueries. By using node-sql-parser, we now inspect the actual AST and accurately detect statement types such as SELECT, INSERT, UPDATE, DELETE, etc. This approach is more reliable and reduces false positives.

…ing only the first token

We used to rely on the first token of the SQL query (e.g., “SELECT”, “UPDATE”) to decide whether it was a read or write query. This was prone to errors when queries started with non-standard tokens or subqueries. By using node-sql-parser, we now inspect the actual AST and accurately detect statement types such as SELECT, INSERT, UPDATE, DELETE, etc. This approach is more reliable and reduces false positives.
@benborla
Copy link
Owner

Love it, thank you for this.

@benborla benborla merged commit 6ac6492 into benborla:main Mar 31, 2025
1 check passed
@jurgenmahn
Copy link
Author

wow that was fast!

@benborla
Copy link
Owner

Tested and working locally. Released at v1.0.21 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants