feat(vet): Introduce a query annotation to opt out of sqlc vet rules#2474
Merged
andrewmbenton merged 3 commits intomainfrom Jul 18, 2023
Merged
feat(vet): Introduce a query annotation to opt out of sqlc vet rules#2474andrewmbenton merged 3 commits intomainfrom
andrewmbenton merged 3 commits intomainfrom
Conversation
kyleconroy
reviewed
Jul 18, 2023
internal/cmd/vet.go
Outdated
| cfg := vetConfig(req) | ||
| for i, query := range req.Queries { | ||
| if result.Queries[i].Flags[QueryFlagSqlcVetDisable] { | ||
| fmt.Printf("Skipping vet rules for query %s", query.Name) |
Collaborator
There was a problem hiding this comment.
I think printing to stderr is fine and more correct than printing to stdout. Can we change the format to match error output? Also, if you want to suppress the output by default, you can check to see if debug.Active is true and only print it then.
fmt.Fprintf(c.Stderr, "%s: %s: %s: skipping\n", query.Filename, q.Name, name)
Collaborator
Author
There was a problem hiding this comment.
The problem with printing to stderr I think is that's where "normal" vet rule errors are reported, so skipping a rule would trigger a vet fail every time right?
The debug.Active check would suppress that except in cases where someone explicitly opted-in, but I'm still not sure it's the right thing to do.
alfonsodev
pushed a commit
to ExponentiaTeam/sqlc
that referenced
this pull request
Oct 13, 2025
…qlc-dev#2474) * feat(vet): Introduce a query annotation to opt out of sqlc vet rules * Add proper logging, and a test * Don't remove comments when parsing query annotation metadata
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.
Introducing the
@sqlc-vet-disablequery annotation, to opt individual queries out of sqlc vet rules, based on #2454.I'm not sure that printing a message to stdout when skipping a query is ideal, but I didn't want to skip silently or return an error and I couldn't use stderr obviously. If skipping silently is better for now I'm happy to remove that line.
Related to the above, I couldn't figure an easy way to test this new functionality without passing in an output stream separate from stderr where a test would expect the skip message to appear. I can do that, but I wasn't sure about the approach and I'm not a testing expert so maybe there's a better thing we could do. Anyway please advise if there's something I should add regarding testing.