-
Notifications
You must be signed in to change notification settings - Fork 832
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
omit_unused_structs generates duplicate enum code #2445
Comments
I've attempted to reproduce here, no luck yet |
drat. OK, i'll see about bisecting my way down to a reproducer. it may take me a while, there's a lot of code to chuck. |
the good news is that that pull request fixes the issue. the bad news is that it exposes a new issue. have to eat dinner now, will file a new issue tomorrow. |
Thanks for taking the time to try this @josharian. If the newly-exposed issue is related to duplicate enums feel free to reopen. |
It turns out the new issue is that we were using one of the newly garbage collected enums in a jsonb schema definition Go struct type. However, we were not using it in any actual database table schemas. As a consequence the Go type for the enum got garbage collected. That seems pretty understandable. And the workaround is easy, if unfortunate: add a dummy placeholder that uses the enum type. |
Actually, the placeholder db table isn't working for me well either. Oh well, I'll just live without this flag in that one spot for now. It's already a major improvement in the other places we use it. |
Version
Other
What happened?
v1.19.0 (not an option in the dropdown)
I added
omit_unused_structs
to our sqlc.yaml.The resulting generated code included duplicate definitions for several enums, including type def, constants, methods, causing a compilation failure.
Unfortunately, I can't reproduce using a trivial example in the playground, and I'm out of debugging time, so I'm filing this in the hopes that the problem is obvious from the symptoms.
Relevant log output
Database schema
SQL queries
No response
Configuration
Playground URL
https://play.sqlc.dev/p/ec4ad0299744dc223ce2402ec06836dedc94d4cf2cf7727950c9e0f284132b44
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: