Title: Queries that `select` optional columns are not unmarshalled into `sql.NullString{}` · Issue #947 · sqlc-dev/sqlc · GitHub
Open Graph Title: Queries that `select` optional columns are not unmarshalled into `sql.NullString{}` · Issue #947 · sqlc-dev/sqlc
X Title: Queries that `select` optional columns are not unmarshalled into `sql.NullString{}` · Issue #947 · sqlc-dev/sqlc
Description: For a given table such as: CREATE TABLE IF NOT EXISTS commodity_type ( id SERIAL PRIMARY KEY, label VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS listings ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), title VARCHAR NOT NULL, price B...
Open Graph Description: For a given table such as: CREATE TABLE IF NOT EXISTS commodity_type ( id SERIAL PRIMARY KEY, label VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS listings ( id UUID PRIMARY KEY DEFAULT uuid_genera...
X Description: For a given table such as: CREATE TABLE IF NOT EXISTS commodity_type ( id SERIAL PRIMARY KEY, label VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS listings ( id UUID PRIMARY KEY DEFAULT uuid_genera...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/947
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Queries that `select` optional columns are not unmarshalled into `sql.NullString{}`","articleBody":"For a given table such as:\r\n```sql\r\nCREATE TABLE IF NOT EXISTS commodity_type (\r\n id SERIAL PRIMARY KEY,\r\n label VARCHAR NOT NULL\r\n);\r\n\r\n\r\nCREATE TABLE IF NOT EXISTS listings (\r\n id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),\r\n title VARCHAR NOT NULL,\r\n price BIGINT NOT NULL,\r\n commodity_type INT,\r\n comments VARCHAR,\r\n FOREIGN KEY (commodity_type) REFERENCES commodity_type(id)\r\n);\r\n```\r\n\r\nand a query such as the following which replaces the id of the optional column `commodity_type` with its `VARCHAR` label:\r\n\r\n```sql\r\nSELECT \r\n title, \r\n price, \r\n comments,\r\n commodity_type.label commodity_type\r\nFROM listings\r\n LEFT JOIN commodity_type ON listings.commodity_type = commodity_type.id ;\r\n```\r\n\r\nthe struct representing such a query resolves to:\r\n\r\n```go\r\ntype GetListingsRow struct {\r\n ID uuid.UUID `json:\"id\"`,\r\n Price int64 `json:\"price\"`,\r\n Comments string `json:\"comments\"`,\r\n CommodityType string `json:\"commodity_type\"`,\r\n}\r\n```\r\nwhich will throw an error when trying to retrieve that row because `converting NULL to string is unsupported`.\r\n\r\nThe expected behaviour is that the optional columns of the query are automatically resolved to `sql.NullString{}` instead of `string`.\r\n\r\nEdit:\r\nOn the other hand: `SELECT * FROM listings;` works as expected.","author":{"url":"https://github.com/honne23","@type":"Person","name":"honne23"},"datePublished":"2021-03-17T10:18:12Z","url":"https://github.com/sqlc-dev/sqlc/issues/947"}
| 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:20ef58e9-add8-c546-0794-e7d150a936c3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8880:11EACE:1FC359B:2A617A7:6B017B2A |
| html-safe-nonce | 38a656adeb23c00e5207b4917241e83137999755984b3de09b294e1f155d4c2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODgwOjExRUFDRToxRkMzNTlCOjJBNjE3QTc6NkIwMTdCMkEiLCJ2aXNpdG9yX2lkIjoiMTUwMDg3MjkwMDI5MzUyNDI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 296a2cae37260a5af22073f11c1e938a4441165a72c9b44842d81a295fe2395e |
| hovercard-subject-tag | issue:833614945 |
| 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/947/issue_layout |
| twitter:image | https://opengraph.githubassets.com/81314093a596f57673d72d8793af36ff670f8101ffd4176e2a3e725ae5ffd218/sqlc-dev/sqlc/issues/947 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/81314093a596f57673d72d8793af36ff670f8101ffd4176e2a3e725ae5ffd218/sqlc-dev/sqlc/issues/947 |
| og:image:alt | For a given table such as: CREATE TABLE IF NOT EXISTS commodity_type ( id SERIAL PRIMARY KEY, label VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS listings ( id UUID PRIMARY KEY DEFAULT uuid_genera... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | honne23 |
| 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