Skip to content
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

[FIX] copyfrom imports #1626

Merged
merged 1 commit into from
May 22, 2022
Merged

Conversation

positiveblue
Copy link
Contributor

Depending on the commands used in your query.sql the copyfrom.go
may end up with unused package imports.

There is a patch for this problem that was merged in the #1386 PR.
However, it looks like some edge cases were left out of the fix.

This commit ensures that buildImports only has copyfrom queries
when called from copyfromImports.

Depending on the commands used in your `query.sql` the `copyfrom.go`
may end up with unused packge imports.

There is a patch for this problem that was merged in the sqlc-dev#1386 PR.
However, it looks like some edge cases were left out of the fix.

This commit ensures that `buildImports` only has `copyfrom` queries
when called from `copyfromImports`.
@@ -6,3 +6,7 @@ INSERT INTO myschema.foo (a, b) VALUES ($1, $2);

-- name: InsertSingleValue :exec
INSERT INTO myschema.foo (a) VALUES ($1);

-- name: DeleteValues :execresult
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the main offender, any file generated from a query file with queries of type metadata.CmdExecResult would include the github.com/jackc/pgconn package

@kyleconroy kyleconroy merged commit 1b6ba1e into sqlc-dev:main May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants