Skip to content

fix(codegen/golang): Don't import "strings" for sqlc.slice() with pgx #3073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/codegen/golang/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (i *importer) queryImports(filename string) fileImports {
}

sqlpkg := parseDriver(i.Options.SqlPackage)
if sqlcSliceScan() {
if sqlcSliceScan() && !sqlpkg.IsPGX() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:( so gross

std["strings"] = struct{}{}
}
if sliceScan() && !sqlpkg.IsPGX() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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'));
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (name text not null);
CREATE TABLE foo (id int not null, name text not null);