Title: Handle Postgres 'NULL' types · Issue #1097 · sqlc-dev/sqlc · GitHub
Open Graph Title: Handle Postgres 'NULL' types · Issue #1097 · sqlc-dev/sqlc
X Title: Handle Postgres 'NULL' types · Issue #1097 · sqlc-dev/sqlc
Description: Hey! For example, I have a schema CREATE TYPE tag AS ENUM ('new', 'stock', 'top'); CREATE TABLE some_table ( ... mainTag tag ... ) You can see that the mainTag field in the table can be null. And for the corresponding table, 'sqlc' gener...
Open Graph Description: Hey! For example, I have a schema CREATE TYPE tag AS ENUM ('new', 'stock', 'top'); CREATE TABLE some_table ( ... mainTag tag ... ) You can see that the mainTag field in the table can be null. And f...
X Description: Hey! For example, I have a schema CREATE TYPE tag AS ENUM ('new', 'stock', 'top'); CREATE TABLE some_table ( ... mainTag tag ... ) You can see that the mainTag field in the ...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1097
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle Postgres 'NULL' types","articleBody":"Hey!\r\nFor example, I have a schema\r\n```sql\r\nCREATE TYPE tag AS ENUM ('new', 'stock', 'top');\r\n\r\nCREATE TABLE some_table (\r\n ...\r\n mainTag tag\r\n ...\r\n)\r\n```\r\nYou can see that the _mainTag_ field in the table can be **null**.\r\nAnd for the corresponding table, 'sqlc' generates me the following code\r\n```go\r\ntype TagType string\r\n\r\nconst (\r\n\tTagTypeNew TagType = \"new\"\r\n\tTagTypeStock TagType = \"stock\"\r\n\tTagTypeTop TagType = \"top\"\r\n)\r\n\r\nfunc (e *TagType) Scan(src interface{}) error {\r\n\tswitch s := src.(type) {\r\n\tcase []byte:\r\n\t\t*e = TagType(s)\r\n\tcase string:\r\n\t\t*e = TagType(s)\r\n\tdefault:\r\n\t\treturn fmt.Errorf(\"unsupported scan type for TagType: %T\", src)\r\n\t}\r\n\treturn nil\r\n}\r\n```\r\n\r\nAfter I try to translate data from the database, I always get an error in the default case: \"unsupported scan type for ....\"\r\n\r\n\r\nQuestion.\r\nSQLC can track that this field can have a **NULL** value in the schema?","author":{"url":"https://github.com/fresonn","@type":"Person","name":"fresonn"},"datePublished":"2021-07-28T10:08:31Z","url":"https://github.com/sqlc-dev/sqlc/issues/1097"}
| 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:5d54c178-6133-a9aa-bf95-a4d7966d94c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D08E:A71F9:18DE181:1F5AFD0:6B017ECE |
| html-safe-nonce | d436c892f168ba83f380f4567407c8315b01fa2de45e5901536af04d18787adf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDhFOkE3MUY5OjE4REUxODE6MUY1QUZEMDo2QjAxN0VDRSIsInZpc2l0b3JfaWQiOiIzOTMxNzEzODcxNzMxMDY0NTI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ab5d7db8b1f152976cd502d23bd846183ca11563e2b8b2c64b8e73df387c1f44 |
| hovercard-subject-tag | issue:954693591 |
| 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/1097/issue_layout |
| twitter:image | https://opengraph.githubassets.com/682270a0e5e37dcbf59c7c26fe82573878171742f6399ea76e80f19681cbee29/sqlc-dev/sqlc/issues/1097 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/682270a0e5e37dcbf59c7c26fe82573878171742f6399ea76e80f19681cbee29/sqlc-dev/sqlc/issues/1097 |
| og:image:alt | Hey! For example, I have a schema CREATE TYPE tag AS ENUM ('new', 'stock', 'top'); CREATE TABLE some_table ( ... mainTag tag ... ) You can see that the mainTag field in the table can be null. And f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fresonn |
| 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