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
{{ message }}
Repository navigation
Optional WHERE parameters via $1 IS NULL OR - redeclared in this block - query_parameter_limit #4191
Fail to generate go gode when using named argument >1 for optional SELECT WHERE query case
see #200
suggested solution does not work in 1.30.0 in golang
would generate go compile error name redeclared in this block
Relevant log output
Go auto-generated code
// ListUsers
//
// SELECT name
// FROM users
// WHERE
// (name = ? OR ? IS NULL)
func (q *Queries) ListUsers(ctx context.Context, name *string, name *string) ([]string, error) {
go build
# query_parameter_limit = 4 (important) will generate (ISSUE) duplicate func args# query_parameter_limit = 1 will generate struct, no duplicate (NO ISSUE)
sqlc/maindb/users.sql.go:25:64: name redeclared in this block
sqlc/maindb/users.sql.go:25:50: other declaration of name
Database schema
CREATETABLEusers (name TEXTNOT NULL);
SQL queries
-- name: ListUsers :manySELECT*FROM users
WHERE
(name =sqlc.narg('name') ORsqlc.narg('name') IS NULL)
changed the title [-]Optional WHERE parameters via $1 IS NULL OR - redeclared in this block[/-][+]Optional WHERE parameters via $1 IS NULL OR - redeclared in this block - query_parameter_limit[/+]on Nov 21, 2025
Activity
sergeishilkocardmarket commentedon Nov 21, 2025
changing
query_parameter_limit: 1emits a proper struct, but when using parameters there is an issue.Is there chance
query_parameter_limitcan be overriden on per-query basis?[-]Optional WHERE parameters via $1 IS NULL OR - redeclared in this block[/-][+]Optional WHERE parameters via $1 IS NULL OR - redeclared in this block - query_parameter_limit[/+]sergeishilkocardmarket commentedon Nov 21, 2025
As a solution to this,
ideally an option to override query_parameter_limit per query,
or option to always use struct argument per query