Title: Error when using CTE and self join · Issue #2132 · sqlc-dev/sqlc · GitHub
Open Graph Title: Error when using CTE and self join · Issue #2132 · sqlc-dev/sqlc
X Title: Error when using CTE and self join · Issue #2132 · sqlc-dev/sqlc
Description: Version 1.17.2 What happened? When using CTE (WITH clause) in query and self join, sqlc doesn't see any columns. When using join from another table/view it works as expected. Relevant log output sqlc generate failed. # package db query.s...
Open Graph Description: Version 1.17.2 What happened? When using CTE (WITH clause) in query and self join, sqlc doesn't see any columns. When using join from another table/view it works as expected. Relevant log output sq...
X Description: Version 1.17.2 What happened? When using CTE (WITH clause) in query and self join, sqlc doesn't see any columns. When using join from another table/view it works as expected. Relevant log outpu...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2132
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error when using CTE and self join","articleBody":"### Version\r\n\r\n1.17.2\r\n\r\n### What happened?\r\n\r\nWhen using CTE (WITH clause) in query and self join, sqlc doesn't see any columns. When using join from another table/view it works as expected.\r\n\r\n### Relevant log output\r\n\r\n```shell\r\nsqlc generate failed.\r\n\r\n# package db\r\nquery.sql:6:5: column \"id\" does not exist\r\n```\r\n\r\n\r\n### Database schema\r\n\r\n_No response_\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: Q :many\r\nWITH\r\n items1 AS (SELECT 'id'::TEXT AS id, 'name'::TEXT AS name),\r\n items2 AS (SELECT 'id'::TEXT AS id, 'name'::TEXT AS name)\r\nSELECT\r\n i1.id AS id1,\r\n i2.id AS id2\r\nFROM\r\n items1 i1\r\n JOIN items1 i2 ON 1 = 1;\r\n -- change ^ above items1 to items2 to fix\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/af3970dbc2ab065393d42b65a2bedf37b0d73734214ca9a42579829dfb8e6de7\r\n\r\n### What operating system are you using?\r\n\r\n_No response_\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/matbur","@type":"Person","name":"matbur"},"datePublished":"2023-03-07T12:37:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2132/sqlc/issues/2132"}
| 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:e4e14564-ab6a-f4e3-38b6-56355cf40b3f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D880:6E5C4:36EEDC:4B1F2F:6A514357 |
| html-safe-nonce | 4c3df888c88159c12f897b5f2ed17b3cc34bb61ac7e4aea4be5905cfcddd443b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODgwOjZFNUM0OjM2RUVEQzo0QjFGMkY6NkE1MTQzNTciLCJ2aXNpdG9yX2lkIjoiNjM4NDE2NTQwMDYwMzYwNzg5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 163f2fa7e32ad18e7eda0ce3e90d066b35d73a8eccceda80d0bac10915b335e6 |
| hovercard-subject-tag | issue:1613356716 |
| 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/2132/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e2ee423dc073072c7171beea75d9a53341b7978667c585e440f3421a4e62380/sqlc-dev/sqlc/issues/2132 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e2ee423dc073072c7171beea75d9a53341b7978667c585e440f3421a4e62380/sqlc-dev/sqlc/issues/2132 |
| og:image:alt | Version 1.17.2 What happened? When using CTE (WITH clause) in query and self join, sqlc doesn't see any columns. When using join from another table/view it works as expected. Relevant log output sq... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matbur |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| 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 | b78565f6aa43cc5323c9935ec11b22cca7bb0a62 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width