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

Redundant import of lib/pq when using sqlc.slice() with sqlc.narg() with MySQL #3420

Open
dskarataev opened this issue Jun 5, 2024 · 1 comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@dskarataev
Copy link

Version

1.26.0

What happened?

When I run sqlc generate with engine: "mysql and I use sqlc.slice(myslice) inside queries, in the generated file with Go code it inserts an import of "github.com/lib/pq" but it is not used in any code so my app does not compile after that.

It happens only when I use it in combination with sqlc.narg(myslice) because I want to ensure that if the argument is null I do not need to filter by it.

The problem is reproducible in the online playground, please look at the link I've attached. Thanks!

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/96994ab9c5be500a74b65ba1e9e870a7dce1fccfae8bc2956909cba197698c5f

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

@dskarataev dskarataev added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 5, 2024
@dskarataev
Copy link
Author

dskarataev commented Jun 5, 2024

Also, could you please guide me maybe how could I use sqlc.slice() to filter by it only in case if there are some elements in the slice? I see the current version of the code generation replaces the slice to NULL in the final SQL, how to use it correctly in that case?

Should it be something like that?

where
    coalesce(name in (sqlc.slice(names)), true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant