Title: SQLC does not infer nullability for subqueries in view SELECT · Issue #4262 · sqlc-dev/sqlc · GitHub
Open Graph Title: SQLC does not infer nullability for subqueries in view SELECT · Issue #4262 · sqlc-dev/sqlc
X Title: SQLC does not infer nullability for subqueries in view SELECT · Issue #4262 · sqlc-dev/sqlc
Description: Version 1.30.0 What happened? I have a DB with a view like so: CREATE VIEW schema.vw_myview AS SELECT p.id AS id_produto, (SELECT i.name FROM public.tb_ibpt i WHERE ((i.code)::text = (p.ncm)::text) LIMIT 1) AS description, ... I would ex...
Open Graph Description: Version 1.30.0 What happened? I have a DB with a view like so: CREATE VIEW schema.vw_myview AS SELECT p.id AS id_produto, (SELECT i.name FROM public.tb_ibpt i WHERE ((i.code)::text = (p.ncm)::text)...
X Description: Version 1.30.0 What happened? I have a DB with a view like so: CREATE VIEW schema.vw_myview AS SELECT p.id AS id_produto, (SELECT i.name FROM public.tb_ibpt i WHERE ((i.code)::text = (p.ncm)::text)...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/4262
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SQLC does not infer nullability for subqueries in view SELECT","articleBody":"### Version\n\n1.30.0\n\n### What happened?\n\nI have a DB with a view like so:\n```\nCREATE VIEW schema.vw_myview AS\n SELECT\n p.id AS id_produto,\n (SELECT i.name\n FROM public.tb_ibpt i\n WHERE ((i.code)::text = (p.ncm)::text)\n LIMIT 1) AS description,\n...\n```\n\nI would expect that selecting the description column in the resulting vw_myview would create a nullable type in the SQLC generated struct, but instead a string field is created. So when there are no matches in the subquery, there is a scan error.\n\n### Relevant log output\n\n```shell\n\n```\n\n### Database schema\n\n```sql\n\n```\n\n### SQL queries\n\n```sql\n\n```\n\n### Configuration\n\n```yaml\nversion: \"2\"\n\nsql:\n - engine: postgresql\n schema: generated.sql\n queries:\n - queries\n gen:\n go:\n package: sqls_erp\n sql_package: \"pgx/v5\"\n out: ../internal/sqls/sql_erp\n emit_json_tags: true\n```\n\n### Playground URL\n\n_No response_\n\n### What operating system are you using?\n\nLinux\n\n### What database engines are you using?\n\nPostgreSQL\n\n### What type of code are you generating?\n\nGo","author":{"url":"https://github.com/lookeey","@type":"Person","name":"lookeey"},"datePublished":"2026-01-14T16:38:09Z","url":"https://github.com/sqlc-dev/sqlc/issues/4262"}
| 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:5f7b41f0-b18f-444b-e717-5b315c376045 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C17A:3DCD28:21F244:2D2711:6B018B52 |
| html-safe-nonce | b3b753bb7190e82060fefddfd775b222d77e23fbe13f1219a2aead5bf501bbc0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTdBOjNEQ0QyODoyMUYyNDQ6MkQyNzExOjZCMDE4QjUyIiwidmlzaXRvcl9pZCI6Ijg0MDk4MjE1ODgyOTk1NDk1MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0a9bba007ba6fc38b5b586c4aea34e19d82230029c200a8339602d4d1e6a42e5 |
| hovercard-subject-tag | issue:3813966398 |
| 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/4262/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b9726f988f07dc8c3689eae7ca13b558b3ade97df3846d5434bc575471e6d7f2/sqlc-dev/sqlc/issues/4262 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b9726f988f07dc8c3689eae7ca13b558b3ade97df3846d5434bc575471e6d7f2/sqlc-dev/sqlc/issues/4262 |
| og:image:alt | Version 1.30.0 What happened? I have a DB with a view like so: CREATE VIEW schema.vw_myview AS SELECT p.id AS id_produto, (SELECT i.name FROM public.tb_ibpt i WHERE ((i.code)::text = (p.ncm)::text)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lookeey |
| 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