Repository navigation
Conversation
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 #4191
With
query_parameter_limitabove the number of parameters, the Go codegen lists each parameter as a method argument. A named parameter used twice (sqlc.narg(name)inname = ? OR ? IS NULL) is two parameters on MySQL, so it producedListUsers(ctx, name sql.NullString, name sql.NullString)and the package did not compile.The struct form already treats such parameters as one field (
columnsToStructgives them the same name andUniqueFieldsdeclares it once).QueryValue.Pairsbuilt the inline argument list from all fields instead. It now usesUniqueFields, so the argument is declared once and still bound to both placeholders.Added an end-to-end case,
query_parameter_limit_repeated_narg, that repeatssqlc.narg(name)alongside another parameter.Ran live:
sqlc generate && go vet ./dbon the issue's schema and query withquery_parameter_limit: 5-> before:name redeclared in this block; after: generatesListUsers(ctx, name sql.NullString, minAge int32)callingQueryContext(..., name, name, minAge)and vet passes.