fix: ignore commented out code when giving warning in SQL editor#16511
Merged
gregnr merged 5 commits intosupabase:masterfrom Aug 21, 2023
Merged
fix: ignore commented out code when giving warning in SQL editor#16511gregnr merged 5 commits intosupabase:masterfrom
gregnr merged 5 commits intosupabase:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
|
@kishanhitk is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
There is an npm package, pg-minify. It claims to remove all types of comments, including nested comments.
Let me know what you think. |
gregnr
reviewed
Aug 21, 2023
gregnr
approved these changes
Aug 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #16484
What does it solve?
The SQL editor warns whenever the SQL command contains any of these keywords:
drop,delete, andtruncate. But the warning shows even if these keywords are part of a commented-out code section.Solution logic:
We use a regex to match if the SQL contains any of those words. I have added an extra function that removes the commented-out code before matching it to the regex.
Alternate solution:
We can update the regex itself to ignore the commented-out code. But, it was getting complex, so I opted for the above approach.
Limitation:
The function to remove commented out code does not work as expected when there is a nested comment.