Title: Bug When Using Table Aliases: `table alias "all_users" does not exist` · Issue #3169 · sqlc-dev/sqlc · GitHub
Open Graph Title: Bug When Using Table Aliases: `table alias "all_users" does not exist` · Issue #3169 · sqlc-dev/sqlc
X Title: Bug When Using Table Aliases: `table alias "all_users" does not exist` · Issue #3169 · sqlc-dev/sqlc
Description: Version 1.25.0 What happened? Sqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_table.field = 'something'. I've provided a s...
Open Graph Description: Version 1.25.0 What happened? Sqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_tabl...
X Description: Version 1.25.0 What happened? Sqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_tabl...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/3169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug When Using Table Aliases: `table alias \"all_users\" does not exist`","articleBody":"### Version\n\n1.25.0\n\n### What happened?\n\nSqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_table.field = 'something'.\r\n\r\nI've provided a simple example to replicate the issue\n\n### Relevant log output\n\n```shell\nsqlc generate failed.\r\n\r\n# package \r\nquery.sql:8:39: table alias \"all_users\" does not exist\n```\n\n\n### Database schema\n\n```sql\n-- Create users table\r\nCREATE TABLE users (\r\n id SERIAL PRIMARY KEY,\r\n email VARCHAR(100) NOT NULL,\r\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\r\n);\r\n\r\n-- Create posts table\r\nCREATE TABLE admins (\r\n id SERIAL PRIMARY KEY,\r\n email VARCHAR(100) NOT NULL,\r\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\r\n);\n```\n\n\n### SQL queries\n\n```sql\n-- name: GetAllUsers :many\r\nWITH all_users AS (\r\n SELECT id, email FROM users\r\n UNION\r\n SELECT id, email FROM admins\r\n)\r\nSELECT id, email FROM all_users where all_users.email=$1;\n```\n\n\n### Configuration\n\n```yaml\nversion: \"2\"\r\nsql:\r\n- schema: \"./db/migrations/\"\r\n queries: \"./pkg/postgres/queries/\"\r\n engine: \"postgresql\"\r\n gen:\r\n go: \r\n package: \"postgres\"\r\n out: \"./pkg/postgres/sqlc\"\r\n emit_json_tags: true\r\n emit_prepared_queries: false\r\n emit_interface: true\r\n emit_exact_table_names: false\r\n emit_empty_slices: true\n```\n\n\n### Playground URL\n\nhttps://play.sqlc.dev/p/388ae1f5e3a9ab6c0185bdfce9ead7acbbb6ece3d6a52d828cd40184b109caf3\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/AvicennaJr","@type":"Person","name":"AvicennaJr"},"datePublished":"2024-02-01T12:52:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/3169/sqlc/issues/3169"}
| 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:8dee60e0-82a8-596d-adc6-256b6356c016 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE54:1F2FB0:1B4EDF:24227F:6A5255D3 |
| html-safe-nonce | 26b990d7c303ebed41680f189be2e2af71b28d8087afb861cd5f8b83d3a787cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTU0OjFGMkZCMDoxQjRFREY6MjQyMjdGOjZBNTI1NUQzIiwidmlzaXRvcl9pZCI6IjQxNjM1ODc1MjA5NjQyMjAzNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4944dd55cba6a856a5ac8eebe2d7a7d68be3b8f4ea81259bbb96ff71e8fa9502 |
| hovercard-subject-tag | issue:2112448818 |
| 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/3169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/743d30d516f08ea9086804c882556c8ff46267f8696ee05753290b406f8b5a4e/sqlc-dev/sqlc/issues/3169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/743d30d516f08ea9086804c882556c8ff46267f8696ee05753290b406f8b5a4e/sqlc-dev/sqlc/issues/3169 |
| og:image:alt | Version 1.25.0 What happened? Sqlc encounters issues when attempting to recognize table aliases specified within the WHERE clause, particularly when filtering selections using the syntax alias_tabl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AvicennaJr |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width