Title: SELECT WITH query with multiple table aliases in FROM get ignored, only last one considered · Issue #1237 · sqlc-dev/sqlc · GitHub
Open Graph Title: SELECT WITH query with multiple table aliases in FROM get ignored, only last one considered · Issue #1237 · sqlc-dev/sqlc
X Title: SELECT WITH query with multiple table aliases in FROM get ignored, only last one considered · Issue #1237 · sqlc-dev/sqlc
Description: Version 1.10.0 What happened? When selecting with SELECT WITH with multiple table aliases in the FROM statement, only the last one on the statements list gets considered. Given the query, we're expecting to select everything from both c1...
Open Graph Description: Version 1.10.0 What happened? When selecting with SELECT WITH with multiple table aliases in the FROM statement, only the last one on the statements list gets considered. Given the query, we're exp...
X Description: Version 1.10.0 What happened? When selecting with SELECT WITH with multiple table aliases in the FROM statement, only the last one on the statements list gets considered. Given the query, we're...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SELECT WITH query with multiple table aliases in FROM get ignored, only last one considered","articleBody":"### Version\n\n1.10.0\n\n### What happened?\n\nWhen selecting with `SELECT WITH` with multiple table aliases in the FROM statement, only the last one on the statements list gets considered.\r\n\r\nGiven the query, we're expecting to select everything from both c1 and c2, but the generated query only selects from c2:\r\n\r\n```sql\r\nWITH\r\n\tq\r\n\t\tAS (\r\n\t\t\tSELECT\r\n\t\t\t\tauthors.name, authors.bio\r\n\t\t\tFROM\r\n\t\t\t\tauthors\r\n\t\t\t\tLEFT JOIN fake ON authors.name = fake.name\r\n\t\t)\r\nSELECT\r\n\tc2.name, c2.bio, c2.name, c2.bio\r\nFROM\r\n\tq AS c1,\r\n\tq as c2\r\n```\n\n### Relevant log output\n\n_No response_\n\n### Database schema\n\n```sql\nCREATE TABLE authors (\r\n id BIGSERIAL PRIMARY KEY,\r\n name text NOT NULL,\r\n bio text\r\n);\r\n\r\nCREATE TABLE fake (\r\n id BIGSERIAL PRIMARY KEY,\r\n name text NOT NULL,\r\n bio text\r\n);\n```\n\n\n### SQL queries\n\n```sql\n-- name: BadQuery :exec\r\nWITH\r\n\tq\r\n\t\tAS (\r\n\t\t\tSELECT\r\n\t\t\t\tauthors.name, authors.bio\r\n\t\t\tFROM\r\n\t\t\t\tauthors\r\n\t\t\t\tLEFT JOIN fake ON authors.name = fake.name\r\n\t\t)\r\nSELECT\r\n\t*\r\nFROM\r\n\tq AS c1,\r\n\tq as c2;\n```\n\n\n### Configuration\n\n```yaml\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}\n```\n\n\n### Playground URL\n\nhttps://play.sqlc.dev/p/79910ee88639b38cdbcbbefeccb1e1a55b8492776ed7fd0a4bbb617217411d46\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/gsora","@type":"Person","name":"gsora"},"datePublished":"2021-10-14T11:57:01Z","url":"https://github.com/sqlc-dev/sqlc/issues/1237"}
| 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:509ffd2a-496c-50db-b242-f8b033d69a95 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C87C:2D2F2F:2581A80:2FE14BE:6B017E63 |
| html-safe-nonce | 90b2be798b988ba9a87fdfaadcb1fb9c477c4e611dcc1bbc290f0511d11f2bb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODdDOjJEMkYyRjoyNTgxQTgwOjJGRTE0QkU6NkIwMTdFNjMiLCJ2aXNpdG9yX2lkIjoiOTExNjQyNDE0ODkzNDAzMjk5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a05f924bafd65758539dd98bf18dee0ba3748dfe254d4d46f0560c1f8959bc7a |
| hovercard-subject-tag | issue:1026307432 |
| 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/1237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f722331a5d5e8cfca605749206c9ae79badbfbd9efd109fac25a499e3547f83f/sqlc-dev/sqlc/issues/1237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f722331a5d5e8cfca605749206c9ae79badbfbd9efd109fac25a499e3547f83f/sqlc-dev/sqlc/issues/1237 |
| og:image:alt | Version 1.10.0 What happened? When selecting with SELECT WITH with multiple table aliases in the FROM statement, only the last one on the statements list gets considered. Given the query, we're exp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gsora |
| 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