Title: LEFT JOIN not generating `Null*` types with table aliases · Issue #1897 · sqlc-dev/sqlc · GitHub
Open Graph Title: LEFT JOIN not generating `Null*` types with table aliases · Issue #1897 · sqlc-dev/sqlc
X Title: LEFT JOIN not generating `Null*` types with table aliases · Issue #1897 · sqlc-dev/sqlc
Description: Version 1.15.0 What happened? sqlc generates incorrect code when using table aliases inside left joins. #1491 was supposed to fix it, but I'm still able to reproduce it. The StripeID field should be of type sql.NullString but it isn't. R...
Open Graph Description: Version 1.15.0 What happened? sqlc generates incorrect code when using table aliases inside left joins. #1491 was supposed to fix it, but I'm still able to reproduce it. The StripeID field should b...
X Description: Version 1.15.0 What happened? sqlc generates incorrect code when using table aliases inside left joins. #1491 was supposed to fix it, but I'm still able to reproduce it. The StripeID field shou...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1897
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"LEFT JOIN not generating `Null*` types with table aliases","articleBody":"### Version\r\n\r\n1.15.0\r\n\r\n### What happened?\r\n\r\nsqlc generates incorrect code when using table aliases inside left joins.\r\n#1491 was supposed to fix it, but I'm still able to reproduce it.\r\nThe `StripeID` field should be of type `sql.NullString` but it isn't.\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 TABLE users (\r\n\tuser_id uuid primary key \r\n);\r\n\r\nCREATE TABLE user_stripe_customers\r\n(\r\n user_id uuid NOT NULL,\r\n stripe_id TEXT NOT NULL,\r\n UNIQUE (user_id, stripe_id)\r\n);\r\nALTER TABLE user_stripe_customers\r\n ADD FOREIGN KEY (user_id) REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE;\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: GetStripeUserByUserID :one\r\nSELECT stripe_id, users.user_id\r\nFROM users\r\n LEFT JOIN user_stripe_customers ON users.user_id = user_stripe_customers.user_id\r\nWHERE users.user_id = @user_id;\r\n\r\n\r\n-- name: GetStripeUserByUserIDBroken :one\r\nSELECT stripe_id, u.user_id\r\nFROM users u\r\n LEFT JOIN user_stripe_customers usu ON u.user_id = usu.user_id\r\nWHERE u.user_id = @user_id;\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 }\r\n ]\r\n}\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/4827a9efa8fd793d7ee704f877890af04675aa382a3942d0f9807a95ae779cf7\r\n\r\n### What operating system are you using?\r\n\r\nmacOS\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/fr3fou","@type":"Person","name":"fr3fou"},"datePublished":"2022-10-13T22:50:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1897/sqlc/issues/1897"}
| 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:f02e7ff7-c0d9-e93b-e6d7-f2943cc68711 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A842:38C420:1A806:24F0F:6A50ECF5 |
| html-safe-nonce | c80e9b714bad7ed43d50093b7b146f09c7659bb481267af0c473f492215466c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODQyOjM4QzQyMDoxQTgwNjoyNEYwRjo2QTUwRUNGNSIsInZpc2l0b3JfaWQiOiI4NTMxMDcyNTkwOTc4MDE4NTQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 520a778ba944bfa949cedfe4d83e63c7637b63fbbfcf8fa5a6023200dee8880b |
| hovercard-subject-tag | issue:1408510807 |
| 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/1897/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8831253225104d4036f4f3f34b9c7d7b49211385c17a1e16250d65b5519c2a4/sqlc-dev/sqlc/issues/1897 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8831253225104d4036f4f3f34b9c7d7b49211385c17a1e16250d65b5519c2a4/sqlc-dev/sqlc/issues/1897 |
| og:image:alt | Version 1.15.0 What happened? sqlc generates incorrect code when using table aliases inside left joins. #1491 was supposed to fix it, but I'm still able to reproduce it. The StripeID field should b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fr3fou |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| 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 | 5ec60191a48933536a90c8a19f47142fcd0d4739 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width