Title: sqlc.Narg does not work with enums · Issue #1683 · sqlc-dev/sqlc · GitHub
Open Graph Title: sqlc.Narg does not work with enums · Issue #1683 · sqlc-dev/sqlc
X Title: sqlc.Narg does not work with enums · Issue #1683 · sqlc-dev/sqlc
Description: Version 1.14.0 What happened? sqlc.narg is a great addition. Unfortunately, it does not seem to work for enum types. I would really like to be able to use nullable enums, as empty strings are invalid enums and throw an error. In the exam...
Open Graph Description: Version 1.14.0 What happened? sqlc.narg is a great addition. Unfortunately, it does not seem to work for enum types. I would really like to be able to use nullable enums, as empty strings are inval...
X Description: Version 1.14.0 What happened? sqlc.narg is a great addition. Unfortunately, it does not seem to work for enum types. I would really like to be able to use nullable enums, as empty strings are inval...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1683
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlc.Narg does not work with enums","articleBody":"### Version\r\n\r\n1.14.0\r\n\r\n### What happened?\r\n\r\nsqlc.narg is a great addition. Unfortunately, it does not seem to work for enum types. I would really like to be able to use nullable enums, as empty strings are invalid enums and throw an error.\r\n\r\nIn the example provided, it would be great if the method definition used `*Colors` to make it nullable:\r\n```golang\r\nfunc (q *Queries) GetBoxes(ctx context.Context, color *Colors) ([]Box, error) {\r\n```\r\n\r\nThe actual method does not accept a nullable argument.\r\n```golang\r\nfunc (q *Queries) GetBoxes(ctx context.Context, color Colors) ([]Box, error) {\r\n```\r\n\r\n### Relevant log output\r\n\r\n_No response_\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TYPE colors AS ENUM (\r\n 'red',\r\n 'blue',\r\n 'green'\r\n);\r\n\r\n-- Example queries for sqlc\r\nCREATE TABLE boxs (\r\n id BIGSERIAL PRIMARY KEY,\r\n name text NOT NULL,\r\n color colors\r\n);\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: GetBoxes :many\r\nSELECT * FROM boxs\r\nWHERE \r\nCASE\r\n\tWHEN sqlc.narg('color') :: colors != null THEN\r\n\t\tcolor = sqlc.narg('color')\r\n\tELSE true\r\nEND;\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n_No response_\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/b269211b4c484293e3e7f8b370d501075e0a355375be9abe1dfb344915601285\r\n\r\n### What operating system are you using?\r\n\r\nLinux\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/Emyrk","@type":"Person","name":"Emyrk"},"datePublished":"2022-06-16T00:40:50Z","url":"https://github.com/sqlc-dev/sqlc/issues/1683"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:815fb064-3b51-cb66-e10c-6c608a68ba25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C72:E9D16:1956474:2011D3C:6B018056 |
| html-safe-nonce | 799c27b7cbabf647570ce9dd272fe1e396ea584d7500fd8ea8f797f880443c8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzcyOkU5RDE2OjE5NTY0NzQ6MjAxMUQzQzo2QjAxODA1NiIsInZpc2l0b3JfaWQiOiI0MDc5OTI0MjU5NTg0MDQ5MjM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e352a73bb5f102c31b5ffd456c0bb69b80c58f6e246b39858a6f1e4601e932e5 |
| hovercard-subject-tag | issue:1272907087 |
| 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/1683/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2bf0ef998ba535fedbfb002485692777c470040377f6f148c25c2c956a9c899f/sqlc-dev/sqlc/issues/1683 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2bf0ef998ba535fedbfb002485692777c470040377f6f148c25c2c956a9c899f/sqlc-dev/sqlc/issues/1683 |
| og:image:alt | Version 1.14.0 What happened? sqlc.narg is a great addition. Unfortunately, it does not seem to work for enum types. I would really like to be able to use nullable enums, as empty strings are inval... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Emyrk |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width