Title: omit_unused_structs ignores enum when used with sqlc.embed · Issue #2860 · sqlc-dev/sqlc · GitHub
Open Graph Title: omit_unused_structs ignores enum when used with sqlc.embed · Issue #2860 · sqlc-dev/sqlc
X Title: omit_unused_structs ignores enum when used with sqlc.embed · Issue #2860 · sqlc-dev/sqlc
Description: Version 1.22.0 What happened? When omit_unused_structs is set to true, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model. Can be circumvented by creating another query without em...
Open Graph Description: Version 1.22.0 What happened? When omit_unused_structs is set to true, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model. Can be circumven...
X Description: Version 1.22.0 What happened? When omit_unused_structs is set to true, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model. Can be circumven...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2860
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"omit_unused_structs ignores enum when used with sqlc.embed","articleBody":"### Version\r\n\r\n1.22.0\r\n\r\n### What happened?\r\n\r\nWhen `omit_unused_structs` is set to `true`, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model.\r\n\r\nCan be circumvented by creating another query without embed just so the enum model exists in the generated code.\r\n\r\n### Relevant log output\r\n\r\ncheck generated models.go\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TYPE enumtype AS ENUM('a','b');\r\n\r\nCREATE TABLE authors (\r\n id BIGSERIAL PRIMARY KEY,\r\n e enumtype not null\r\n);\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: GetAllAuthors :one\r\nSELECT sqlc.embed(authors) FROM authors;\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n```yaml\r\n{\r\n \"version\": \"1\",\r\n \"packages\": [\r\n {\r\n \"path\": \"db\",\r\n \"engine\": \"postgresql\",\r\n \"schema\": \"query.sql\",\r\n \"queries\": \"query.sql\",\r\n \"omit_unused_structs\": true\r\n }\r\n ]\r\n}\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/2203df48ffefbead62b4871ccb2269b8cdd425c64c27108b7857d79c89a5596d\r\n\r\n### What operating system are you using?\r\n\r\nLinux, Windows\r\n\r\n### What database engines are you using?\r\n\r\nPostgreSQL\r\n\r\n### What type of code are you generating?\r\n\r\nGo","author":{"url":"https://github.com/Andy-William","@type":"Person","name":"Andy-William"},"datePublished":"2023-10-16T11:31:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2860/sqlc/issues/2860"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4110ee93-26d8-735c-79dc-83dff09b69bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECC6:DC47A:1FBCD5:2BC3D3:6A505F56 |
| html-safe-nonce | 6749a37926deb7bd9167956c59bd7d187f4cb371dff96929bf7165c0ab067f9c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0M2OkRDNDdBOjFGQkNENToyQkMzRDM6NkE1MDVGNTYiLCJ2aXNpdG9yX2lkIjoiNTc1NzU0NjkzMzU5MDcxMjE1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ebae96943f1e7836703c44f80afc7bd34323e979c0c4980b5545ec9b6364d1fa |
| hovercard-subject-tag | issue:1944999808 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc/2860/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7bfd60e833713817ee33fbba6de7610994572226b0da7df51609dae1489a3a9c/sqlc-dev/sqlc/issues/2860 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7bfd60e833713817ee33fbba6de7610994572226b0da7df51609dae1489a3a9c/sqlc-dev/sqlc/issues/2860 |
| og:image:alt | Version 1.22.0 What happened? When omit_unused_structs is set to true, enums inside an sqlc.embed is ignored. This can cause invalid golang code due to undefined type on the model. Can be circumven... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andy-William |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 193160679 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193160679 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width