Repository: sqlc-dev/sqlc
Pull request #3073 (2023-12-20 18:12:43)

fix(codegen/golang): Don't import `"strings"` for `sqlc.slice()` with pgx
Also fix the invalid test that should have caught this.

Resolves https://github.com/sqlc-dev/sqlc/issues/3065


Patch:
diff --git a/go.mod b/go.mod
index 62640248b..8292baca8 100644
--- a/go.mod
+++ b/go.mod
@@ -23,7 +23,7 @@ require (
 	github.com/wasilibs/go-pgquery v0.0.0-20231208014744-de63626a1e99
 	github.com/xeipuuv/gojsonschema v1.2.0
 	golang.org/x/sync v0.5.0
-	google.golang.org/grpc v1.60.0
+	google.golang.org/grpc v1.60.1
 	google.golang.org/protobuf v1.31.0
 	gopkg.in/yaml.v3 v3.0.1
 	modernc.org/sqlite v1.28.0
@@ -59,11 +59,11 @@ require (
 	go.uber.org/atomic v1.11.0 // indirect
 	go.uber.org/multierr v1.11.0 // indirect
 	go.uber.org/zap v1.26.0 // indirect
-	golang.org/x/crypto v0.14.0 // indirect
+	golang.org/x/crypto v0.17.0 // indirect
 	golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
 	golang.org/x/mod v0.13.0 // indirect
 	golang.org/x/net v0.17.0 // indirect
-	golang.org/x/sys v0.13.0 // indirect
+	golang.org/x/sys v0.15.0 // indirect
 	golang.org/x/text v0.14.0 // indirect
 	golang.org/x/tools v0.14.0 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
diff --git a/go.sum b/go.sum
index c06c03d53..766b48496 100644
--- a/go.sum
+++ b/go.sum
@@ -233,8 +233,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y
 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
-golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
-golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
+golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
+golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
 golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
 golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
 golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
@@ -272,8 +272,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
-golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
+golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -310,8 +310,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:
 google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0=
 google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0=
 google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY=
-google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k=
-google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
+google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
+google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
 google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
diff --git a/internal/codegen/golang/imports.go b/internal/codegen/golang/imports.go
index 83f72cd78..caa96ffe2 100644
--- a/internal/codegen/golang/imports.go
+++ b/internal/codegen/golang/imports.go
@@ -390,7 +390,7 @@ func (i *importer) queryImports(filename string) fileImports {
 	}
 
 	sqlpkg := parseDriver(i.Options.SqlPackage)
-	if sqlcSliceScan() {
+	if sqlcSliceScan() && !sqlpkg.IsPGX() {
 		std["strings"] = struct{}{}
 	}
 	if sliceScan() && !sqlpkg.IsPGX() {
diff --git a/internal/compiler/parse.go b/internal/compiler/parse.go
index 8f4727144..022d23ea2 100644
--- a/internal/compiler/parse.go
+++ b/internal/compiler/parse.go
@@ -46,6 +46,10 @@ func (c *Compiler) parseQuery(stmt ast.Node, src string, o opts.Parser) (*Query,
 		return nil, err
 	}
 
+	if name == "" {
+		return nil, nil
+	}
+
 	if err := validate.Cmd(raw.Stmt, name, cmd); err != nil {
 		return nil, err
 	}


Test patch:
diff --git a/internal/endtoend/testdata/builtins/postgresql/exec.json b/internal/endtoend/testdata/builtins/postgresql/exec.json
new file mode 100644
index 000000000..97f81fbc6
--- /dev/null
+++ b/internal/endtoend/testdata/builtins/postgresql/exec.json
@@ -0,0 +1,3 @@
+{
+    "contexts": ["base"]
+}
diff --git a/internal/endtoend/testdata/builtins/postgresql/go/query.sql.go b/internal/endtoend/testdata/builtins/postgresql/go/query.sql.go
new file mode 100644
index 000000000..395ebeff8
--- /dev/null
+++ b/internal/endtoend/testdata/builtins/postgresql/go/query.sql.go
@@ -0,0 +1,274 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package querytest
+
+import (
+	"context"
+)
+
+const abs = `-- name: Abs :one
+SELECT abs(-17.4)
+`
+
+func (q *Queries) Abs(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, abs)
+	var abs int64
+	err := row.Scan(&abs)
+	return abs, err
+}
+
+const cbrt = `-- name: Cbrt :one
+SELECT cbrt(27.0)
+`
+
+func (q *Queries) Cbrt(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, cbrt)
+	var cbrt float64
+	err := row.Scan(&cbrt)
+	return cbrt, err
+}
+
+const ceil = `-- name: Ceil :one
+SELECT ceil(-42.8)
+`
+
+func (q *Queries) Ceil(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, ceil)
+	var ceil float64
+	err := row.Scan(&ceil)
+	return ceil, err
+}
+
+const ceiling = `-- name: Ceiling :one
+SELECT ceiling(-95.3)
+`
+
+func (q *Queries) Ceiling(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, ceiling)
+	var ceiling float64
+	err := row.Scan(&ceiling)
+	return ceiling, err
+}
+
+const degrees = `-- name: Degrees :one
+SELECT degrees(0.5)
+`
+
+func (q *Queries) Degrees(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, degrees)
+	var degrees float64
+	err := row.Scan(&degrees)
+	return degrees, err
+}
+
+const div = `-- name: Div :one
+SELECT div(9,4)
+`
+
+func (q *Queries) Div(ctx context.Context) (string, error) {
+	row := q.db.QueryRowContext(ctx, div)
+	var div string
+	err := row.Scan(&div)
+	return div, err
+}
+
+const exp = `-- name: Exp :one
+SELECT exp(1.0)
+`
+
+func (q *Queries) Exp(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, exp)
+	var exp float64
+	err := row.Scan(&exp)
+	return exp, err
+}
+
+const floor = `-- name: Floor :one
+SELECT floor(-42.8)
+`
+
+func (q *Queries) Floor(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, floor)
+	var floor float64
+	err := row.Scan(&floor)
+	return floor, err
+}
+
+const ln = `-- name: Ln :one
+SELECT ln(2.0)
+`
+
+func (q *Queries) Ln(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, ln)
+	var ln float64
+	err := row.Scan(&ln)
+	return ln, err
+}
+
+const log = `-- name: Log :one
+SELECT log(100.0)
+`
+
+func (q *Queries) Log(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, log)
+	var log float64
+	err := row.Scan(&log)
+	return log, err
+}
+
+const logs = `-- name: Logs :one
+SELECT log(2.0, 64.0)
+`
+
+func (q *Queries) Logs(ctx context.Context) (string, error) {
+	row := q.db.QueryRowContext(ctx, logs)
+	var log string
+	err := row.Scan(&log)
+	return log, err
+}
+
+const mod = `-- name: Mod :one
+SELECT mod(9,4)
+`
+
+func (q *Queries) Mod(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, mod)
+	var mod int64
+	err := row.Scan(&mod)
+	return mod, err
+}
+
+const pi = `-- name: Pi :one
+SELECT pi()
+`
+
+func (q *Queries) Pi(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, pi)
+	var pi float64
+	err := row.Scan(&pi)
+	return pi, err
+}
+
+const power = `-- name: Power :one
+SELECT power(9.0, 3.0)
+`
+
+func (q *Queries) Power(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, power)
+	var power float64
+	err := row.Scan(&power)
+	return power, err
+}
+
+const radians = `-- name: Radians :one
+SELECT radians(45.0)
+`
+
+func (q *Queries) Radians(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, radians)
+	var radians float64
+	err := row.Scan(&radians)
+	return radians, err
+}
+
+const round = `-- name: Round :one
+SELECT round(42.4)
+`
+
+func (q *Queries) Round(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, round)
+	var round float64
+	err := row.Scan(&round)
+	return round, err
+}
+
+const rounds = `-- name: Rounds :one
+SELECT round(42.4382, 2)
+`
+
+func (q *Queries) Rounds(ctx context.Context) (string, error) {
+	row := q.db.QueryRowContext(ctx, rounds)
+	var round string
+	err := row.Scan(&round)
+	return round, err
+}
+
+const scale = `-- name: Scale :one
+SELECT scale(8.41)
+`
+
+func (q *Queries) Scale(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, scale)
+	var scale int32
+	err := row.Scan(&scale)
+	return scale, err
+}
+
+const sign = `-- name: Sign :one
+SELECT sign(-8.4)
+`
+
+func (q *Queries) Sign(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, sign)
+	var sign float64
+	err := row.Scan(&sign)
+	return sign, err
+}
+
+const sqrt = `-- name: Sqrt :one
+SELECT sqrt(2.0)
+`
+
+func (q *Queries) Sqrt(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, sqrt)
+	var sqrt float64
+	err := row.Scan(&sqrt)
+	return sqrt, err
+}
+
+const trunc = `-- name: Trunc :one
+SELECT trunc(42.8)
+`
+
+func (q *Queries) Trunc(ctx context.Context) (float64, error) {
+	row := q.db.QueryRowContext(ctx, trunc)
+	var trunc float64
+	err := row.Scan(&trunc)
+	return trunc, err
+}
+
+const truncs = `-- name: Truncs :one
+SELECT trunc(42.4382, 2)
+`
+
+func (q *Queries) Truncs(ctx context.Context) (string, error) {
+	row := q.db.QueryRowContext(ctx, truncs)
+	var trunc string
+	err := row.Scan(&trunc)
+	return trunc, err
+}
+
+const widthBucketNumerics = `-- name: WidthBucketNumerics :one
+SELECT width_bucket(5.35, 0.024, 10.06, 5)
+`
+
+func (q *Queries) WidthBucketNumerics(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, widthBucketNumerics)
+	var width_bucket int32
+	err := row.Scan(&width_bucket)
+	return width_bucket, err
+}
+
+const widthBucketTimestamps = `-- name: WidthBucketTimestamps :one
+SELECT width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])
+`
+
+func (q *Queries) WidthBucketTimestamps(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, widthBucketTimestamps)
+	var width_bucket int32
+	err := row.Scan(&width_bucket)
+	return width_bucket, err
+}
diff --git a/internal/endtoend/testdata/builtins/postgresql/query.sql b/internal/endtoend/testdata/builtins/postgresql/query.sql
index ee4723f8e..2c62e5f77 100644
--- a/internal/endtoend/testdata/builtins/postgresql/query.sql
+++ b/internal/endtoend/testdata/builtins/postgresql/query.sql
@@ -1,25 +1,48 @@
+-- name: Abs :one
 SELECT abs(-17.4);
+-- name: Cbrt :one
 SELECT cbrt(27.0);
+-- name: Ceil :one
 SELECT ceil(-42.8);
+-- name: Ceiling :one
 SELECT ceiling(-95.3);
+-- name: Degrees :one
 SELECT degrees(0.5);
+-- name: Div :one
 SELECT div(9,4);
+-- name: Exp :one
 SELECT exp(1.0);
+-- name: Floor :one
 SELECT floor(-42.8);
+-- name: Ln :one
 SELECT ln(2.0);
+-- name: Log :one
 SELECT log(100.0);
+-- name: Logs :one
 SELECT log(2.0, 64.0);
+-- name: Mod :one
 SELECT mod(9,4);
+-- name: Pi :one
 SELECT pi();
+-- name: Power :one
 SELECT power(9.0, 3.0);
+-- name: Radians :one
 SELECT radians(45.0);
+-- name: Round :one
 SELECT round(42.4);
+-- name: Rounds :one
 SELECT round(42.4382, 2);
+-- name: Scale :one
 SELECT scale(8.41);
+-- name: Sign :one
 SELECT sign(-8.4);
+-- name: Sqrt :one
 SELECT sqrt(2.0);
+-- name: Trunc :one
 SELECT trunc(42.8);
+-- name: Truncs :one
 SELECT trunc(42.4382, 2);
+-- name: WidthBucketNumerics :one
 SELECT width_bucket(5.35, 0.024, 10.06, 5);
+-- name: WidthBucketTimestamps :one
 SELECT width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[]);
-create schema if not exists sqlc;
diff --git a/internal/endtoend/testdata/datatype/mysql/go/query.sql.go b/internal/endtoend/testdata/datatype/mysql/go/query.sql.go
new file mode 100644
index 000000000..b24131a8a
--- /dev/null
+++ b/internal/endtoend/testdata/datatype/mysql/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/datatype/mysql/sql/query.sql b/internal/endtoend/testdata/datatype/mysql/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/datatype/mysql/sql/query.sql
+++ b/internal/endtoend/testdata/datatype/mysql/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/datatype/pgx/v4/go/query.sql.go b/internal/endtoend/testdata/datatype/pgx/v4/go/query.sql.go
new file mode 100644
index 000000000..cb61ac7fc
--- /dev/null
+++ b/internal/endtoend/testdata/datatype/pgx/v4/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/datatype/pgx/v4/sql/query.sql b/internal/endtoend/testdata/datatype/pgx/v4/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/datatype/pgx/v4/sql/query.sql
+++ b/internal/endtoend/testdata/datatype/pgx/v4/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/datatype/pgx/v5/go/query.sql.go b/internal/endtoend/testdata/datatype/pgx/v5/go/query.sql.go
new file mode 100644
index 000000000..cb61ac7fc
--- /dev/null
+++ b/internal/endtoend/testdata/datatype/pgx/v5/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/datatype/pgx/v5/sql/query.sql b/internal/endtoend/testdata/datatype/pgx/v5/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/datatype/pgx/v5/sql/query.sql
+++ b/internal/endtoend/testdata/datatype/pgx/v5/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/datatype/sqlite/go/query.sql.go b/internal/endtoend/testdata/datatype/sqlite/go/query.sql.go
new file mode 100644
index 000000000..c2744a459
--- /dev/null
+++ b/internal/endtoend/testdata/datatype/sqlite/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int64
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/datatype/sqlite/sql/query.sql b/internal/endtoend/testdata/datatype/sqlite/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/datatype/sqlite/sql/query.sql
+++ b/internal/endtoend/testdata/datatype/sqlite/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/datatype/stdlib/go/query.sql.go b/internal/endtoend/testdata/datatype/stdlib/go/query.sql.go
new file mode 100644
index 000000000..b24131a8a
--- /dev/null
+++ b/internal/endtoend/testdata/datatype/stdlib/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/datatype/stdlib/sql/query.sql b/internal/endtoend/testdata/datatype/stdlib/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/datatype/stdlib/sql/query.sql
+++ b/internal/endtoend/testdata/datatype/stdlib/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/go/query.sql.go b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/go/query.sql.go
new file mode 100644
index 000000000..cb61ac7fc
--- /dev/null
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/sql/query.sql b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/sql/query.sql
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v4/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/go/query.sql.go b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/go/query.sql.go
new file mode 100644
index 000000000..cb61ac7fc
--- /dev/null
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/sql/query.sql b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/sql/query.sql
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/pgx/v5/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/go/query.sql.go b/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/go/query.sql.go
new file mode 100644
index 000000000..b24131a8a
--- /dev/null
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package datatype
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/sql/query.sql b/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/sql/query.sql
+++ b/internal/endtoend/testdata/emit_pointers_for_null_types/stdlib/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v4/query.sql b/internal/endtoend/testdata/invalid_func_args/pgx/v4/query.sql
index 46dbe9fa2..e92c21d81 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v4/query.sql
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v4/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT random(1);
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/base.txt b/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/base.txt
index 09d46d1f9..2693a0846 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/base.txt
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/base.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(unknown) does not exist
+query.sql:2:8: function random(unknown) does not exist
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/managed-db.txt b/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/managed-db.txt
index 34430f733..d211139c8 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/managed-db.txt
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v4/stderr/managed-db.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(integer) does not exist
+query.sql:2:8: function random(integer) does not exist
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v5/query.sql b/internal/endtoend/testdata/invalid_func_args/pgx/v5/query.sql
index 46dbe9fa2..e92c21d81 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v5/query.sql
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v5/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT random(1);
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/base.txt b/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/base.txt
index 09d46d1f9..2693a0846 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/base.txt
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/base.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(unknown) does not exist
+query.sql:2:8: function random(unknown) does not exist
diff --git a/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/managed-db.txt b/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/managed-db.txt
index 34430f733..d211139c8 100644
--- a/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/managed-db.txt
+++ b/internal/endtoend/testdata/invalid_func_args/pgx/v5/stderr/managed-db.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(integer) does not exist
+query.sql:2:8: function random(integer) does not exist
diff --git a/internal/endtoend/testdata/invalid_func_args/stdlib/query.sql b/internal/endtoend/testdata/invalid_func_args/stdlib/query.sql
index 46dbe9fa2..e92c21d81 100644
--- a/internal/endtoend/testdata/invalid_func_args/stdlib/query.sql
+++ b/internal/endtoend/testdata/invalid_func_args/stdlib/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT random(1);
diff --git a/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/base.txt b/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/base.txt
index 09d46d1f9..2693a0846 100644
--- a/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/base.txt
+++ b/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/base.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(unknown) does not exist
+query.sql:2:8: function random(unknown) does not exist
diff --git a/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/managed-db.txt b/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/managed-db.txt
index 34430f733..d211139c8 100644
--- a/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/managed-db.txt
+++ b/internal/endtoend/testdata/invalid_func_args/stdlib/stderr/managed-db.txt
@@ -1,2 +1,2 @@
 # package querytest
-query.sql:1:8: function random(integer) does not exist
+query.sql:2:8: function random(integer) does not exist
diff --git a/internal/endtoend/testdata/overrides/mysql/go/query.sql.go b/internal/endtoend/testdata/overrides/mysql/go/query.sql.go
new file mode 100644
index 000000000..3cbff990d
--- /dev/null
+++ b/internal/endtoend/testdata/overrides/mysql/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides/mysql/query.sql b/internal/endtoend/testdata/overrides/mysql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides/mysql/query.sql
+++ b/internal/endtoend/testdata/overrides/mysql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides/postgresql/pgx/v4/go/query.sql.go b/internal/endtoend/testdata/overrides/postgresql/pgx/v4/go/query.sql.go
new file mode 100644
index 000000000..3eb7630b2
--- /dev/null
+++ b/internal/endtoend/testdata/overrides/postgresql/pgx/v4/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides/postgresql/pgx/v4/query.sql b/internal/endtoend/testdata/overrides/postgresql/pgx/v4/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides/postgresql/pgx/v4/query.sql
+++ b/internal/endtoend/testdata/overrides/postgresql/pgx/v4/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides/postgresql/pgx/v5/go/query.sql.go b/internal/endtoend/testdata/overrides/postgresql/pgx/v5/go/query.sql.go
new file mode 100644
index 000000000..3eb7630b2
--- /dev/null
+++ b/internal/endtoend/testdata/overrides/postgresql/pgx/v5/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides/postgresql/pgx/v5/query.sql b/internal/endtoend/testdata/overrides/postgresql/pgx/v5/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides/postgresql/pgx/v5/query.sql
+++ b/internal/endtoend/testdata/overrides/postgresql/pgx/v5/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides/postgresql/stdlib/go/query.sql.go b/internal/endtoend/testdata/overrides/postgresql/stdlib/go/query.sql.go
new file mode 100644
index 000000000..3cbff990d
--- /dev/null
+++ b/internal/endtoend/testdata/overrides/postgresql/stdlib/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides/postgresql/stdlib/query.sql b/internal/endtoend/testdata/overrides/postgresql/stdlib/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides/postgresql/stdlib/query.sql
+++ b/internal/endtoend/testdata/overrides/postgresql/stdlib/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides/sqlite/go/query.sql.go b/internal/endtoend/testdata/overrides/sqlite/go/query.sql.go
new file mode 100644
index 000000000..015fa0c01
--- /dev/null
+++ b/internal/endtoend/testdata/overrides/sqlite/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int64
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides/sqlite/query.sql b/internal/endtoend/testdata/overrides/sqlite/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides/sqlite/query.sql
+++ b/internal/endtoend/testdata/overrides/sqlite/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_config/query.sql b/internal/endtoend/testdata/overrides_config/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_config/query.sql
+++ b/internal/endtoend/testdata/overrides_config/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_config/v2/yaml/global/db/query.sql.go b/internal/endtoend/testdata/overrides_config/v2/yaml/global/db/query.sql.go
new file mode 100644
index 000000000..10ef067df
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_config/v2/yaml/global/db/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package db
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_config/v2/yaml/global_and_queryset/db/query.sql.go b/internal/endtoend/testdata/overrides_config/v2/yaml/global_and_queryset/db/query.sql.go
new file mode 100644
index 000000000..10ef067df
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_config/v2/yaml/global_and_queryset/db/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package db
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_config/v2/yaml/queryset/db/query.sql.go b/internal/endtoend/testdata/overrides_config/v2/yaml/queryset/db/query.sql.go
new file mode 100644
index 000000000..10ef067df
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_config/v2/yaml/queryset/db/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package db
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/invalid_tags/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/mysql/go/query.sql.go b/internal/endtoend/testdata/overrides_go_struct_tags/mysql/go/query.sql.go
new file mode 100644
index 000000000..3cbff990d
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/mysql/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/mysql/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/mysql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/mysql/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/mysql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/go/query.sql.go b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/go/query.sql.go
new file mode 100644
index 000000000..3eb7630b2
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v4/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/go/query.sql.go b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/go/query.sql.go
new file mode 100644
index 000000000..3eb7630b2
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRow(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/pgx/v5/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/go/query.sql.go b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/go/query.sql.go
new file mode 100644
index 000000000..3cbff990d
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/postgresql/stdlib/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/query.sql.go b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/query.sql.go
new file mode 100644
index 000000000..015fa0c01
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int64
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/query.sql b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/query.sql
+++ b/internal/endtoend/testdata/overrides_go_struct_tags/sqlite/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/overrides_go_types/sqlite/go/query.sql.go b/internal/endtoend/testdata/overrides_go_types/sqlite/go/query.sql.go
new file mode 100644
index 000000000..015fa0c01
--- /dev/null
+++ b/internal/endtoend/testdata/overrides_go_types/sqlite/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int64, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int64
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/overrides_go_types/sqlite/query.sql b/internal/endtoend/testdata/overrides_go_types/sqlite/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/overrides_go_types/sqlite/query.sql
+++ b/internal/endtoend/testdata/overrides_go_types/sqlite/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;
diff --git a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/models.go b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/models.go
index f2489a04c..dbec851f1 100644
--- a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/models.go
+++ b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/models.go
@@ -7,5 +7,6 @@ package querytest
 import ()
 
 type Foo struct {
+	ID   int32
 	Name string
 }
diff --git a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/query.sql.go b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/query.sql.go
index aa0d38000..5e6930847 100644
--- a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/query.sql.go
+++ b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/go/query.sql.go
@@ -11,10 +11,16 @@ import (
 
 const funcParamIdent = `-- name: FuncParamIdent :many
 SELECT name FROM foo WHERE name = $1
+  AND id IN ($2)
 `
 
-func (q *Queries) FuncParamIdent(ctx context.Context, slug string) ([]string, error) {
-	rows, err := q.db.Query(ctx, funcParamIdent, slug)
+type FuncParamIdentParams struct {
+	Slug       string
+	Favourites []int32
+}
+
+func (q *Queries) FuncParamIdent(ctx context.Context, arg FuncParamIdentParams) ([]string, error) {
+	rows, err := q.db.Query(ctx, funcParamIdent, arg.Slug, arg.Favourites)
 	if err != nil {
 		return nil, err
 	}
@@ -35,10 +41,16 @@ func (q *Queries) FuncParamIdent(ctx context.Context, slug string) ([]string, er
 
 const funcParamString = `-- name: FuncParamString :many
 SELECT name FROM foo WHERE name = $1
+  AND id IN ($2)
 `
 
-func (q *Queries) FuncParamString(ctx context.Context, slug string) ([]string, error) {
-	rows, err := q.db.Query(ctx, funcParamString, slug)
+type FuncParamStringParams struct {
+	Slug       string
+	Favourites []int32
+}
+
+func (q *Queries) FuncParamString(ctx context.Context, arg FuncParamStringParams) ([]string, error) {
+	rows, err := q.db.Query(ctx, funcParamString, arg.Slug, arg.Favourites)
 	if err != nil {
 		return nil, err
 	}
diff --git a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/query.sql b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/query.sql
index 2dfaa9cd5..2a5fccf1f 100644
--- a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/query.sql
+++ b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/query.sql
@@ -1,5 +1,7 @@
 -- name: FuncParamIdent :many
-SELECT name FROM foo WHERE name = sqlc.arg(slug);
+SELECT name FROM foo WHERE name = sqlc.arg(slug)
+  AND id IN (sqlc.slice(favourites));
 
 -- name: FuncParamString :many
-SELECT name FROM foo WHERE name = sqlc.arg('slug');
+SELECT name FROM foo WHERE name = sqlc.arg('slug')
+  AND id IN (sqlc.slice('favourites'));
diff --git a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/schema.sql b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/schema.sql
index ec46e55cc..43e6433e3 100644
--- a/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/schema.sql
+++ b/internal/endtoend/testdata/sqlc_slice/postgresql/pgx/schema.sql
@@ -1,2 +1,2 @@
-CREATE TABLE foo (name text not null);
+CREATE TABLE foo (id int not null, name text not null);
 
diff --git a/internal/endtoend/testdata/yaml_overrides/go/query.sql.go b/internal/endtoend/testdata/yaml_overrides/go/query.sql.go
new file mode 100644
index 000000000..3cbff990d
--- /dev/null
+++ b/internal/endtoend/testdata/yaml_overrides/go/query.sql.go
@@ -0,0 +1,21 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.24.0
+// source: query.sql
+
+package override
+
+import (
+	"context"
+)
+
+const test = `-- name: Test :one
+SELECT 1
+`
+
+func (q *Queries) Test(ctx context.Context) (int32, error) {
+	row := q.db.QueryRowContext(ctx, test)
+	var column_1 int32
+	err := row.Scan(&column_1)
+	return column_1, err
+}
diff --git a/internal/endtoend/testdata/yaml_overrides/sql/query.sql b/internal/endtoend/testdata/yaml_overrides/sql/query.sql
index e0ac49d1e..9da604b57 100644
--- a/internal/endtoend/testdata/yaml_overrides/sql/query.sql
+++ b/internal/endtoend/testdata/yaml_overrides/sql/query.sql
@@ -1,1 +1,2 @@
+-- name: Test :one
 SELECT 1;