Title: incorrect ambiguous reference check · Issue #2398 · sqlc-dev/sqlc · GitHub
Open Graph Title: incorrect ambiguous reference check · Issue #2398 · sqlc-dev/sqlc
X Title: incorrect ambiguous reference check · Issue #2398 · sqlc-dev/sqlc
Description: Version 1.18.0 What happened? There seems to be a minor bug in checking ambiguous references when joning tables while using alias. To reproduce, change the sqlc/internal/endtoend/testdata/order_by_non_existing_column/postgresql to -- Exa...
Open Graph Description: Version 1.18.0 What happened? There seems to be a minor bug in checking ambiguous references when joning tables while using alias. To reproduce, change the sqlc/internal/endtoend/testdata/order_by_...
X Description: Version 1.18.0 What happened? There seems to be a minor bug in checking ambiguous references when joning tables while using alias. To reproduce, change the sqlc/internal/endtoend/testdata/order_by_...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2398
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"incorrect ambiguous reference check","articleBody":"### Version\n\n1.18.0\n\n### What happened?\n\n\r\nThere seems to be a minor bug in checking ambiguous references when joning tables while using alias.\r\n\r\nTo reproduce, change the `sqlc/internal/endtoend/testdata/order_by_non_existing_column/postgresql` to\r\n```\r\n-- Example queries for sqlc\r\nCREATE TABLE authors (\r\n id INT\r\n);\r\n\r\nCREATE TABLE books (\r\n id INT,\r\n author_id INT,\r\n price INT\r\n);\r\n\r\n-- name: ListAuthors :many\r\nSELECT id FROM authors\r\nORDER BY adfadsf;\r\n\r\n-- name: ListAuthorsByCheapestBook :many\r\nSELECT\r\nauthor_id, min(b.price) as min_price\r\nFrom books b inner join authors a on a.id = b.author_id\r\nGROUP BY b.author_id\r\nORDER BY min_price;\r\n```\r\n\r\nThe column of min_price is not ambiguous but sqlc reports:\r\n```\r\n# package \r\nquery.sql:13:1: column reference \"adfadsf\" not found: if you want to skip this validation, set 'strict_order_by' to false\r\nquery.sql:17:1: column reference \"min_price\" is ambiguous: if you want to skip this validation, set 'strict_order_by' to false\r\n\r\n```\n\n### Relevant log output\n\n```shell\nquery.sql:13:1: column reference \"adfadsf\" not found: if you want to skip this validation, set 'strict_order_by' to false\r\nquery.sql:17:1: column reference \"min_price\" is ambiguous: if you want to skip this validation, set 'strict_order_by' to false\n```\n\n\n### Database schema\n\n```sql\nCREATE TABLE authors (\r\n id INT\r\n);\r\n\r\nCREATE TABLE books (\r\n id INT,\r\n author_id INT,\r\n price INT\r\n);\n```\n\n\n### SQL queries\n\n```sql\n-- name: ListAuthorsByCheapestBook :many\r\nSELECT\r\nauthor_id, min(b.price) as min_price\r\nFrom books b inner join authors a on a.id = b.author_id\r\nGROUP BY b.author_id\r\nORDER BY min_price;\n```\n\n\n### Configuration\n\n_No response_\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/Stumble","@type":"Person","name":"Stumble"},"datePublished":"2023-06-30T23:54:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2398/sqlc/issues/2398"}
| 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:4799e9e4-ac75-6cae-6e59-db0c1ac08c01 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FEA:1480EB:DF7A43:12A7D1B:6A52A794 |
| html-safe-nonce | 468b94b8d130b6d488ba4bac32fb40ba7f861dfa5e1e1acaddcb8fa94ac4e6ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkVBOjE0ODBFQjpERjdBNDM6MTJBN0QxQjo2QTUyQTc5NCIsInZpc2l0b3JfaWQiOiI0NTYzMzQyODAwMzM1MzE2ODg0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e3b49fe4c2111ae98a30f5877258fbfdf0631c5ac57a4510aea9328256770c01 |
| hovercard-subject-tag | issue:1783264865 |
| 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/2398/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5f0243b34df3f8b407336969610f828773ee10c14fff6c04f653eaf25dbb62c4/sqlc-dev/sqlc/issues/2398 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5f0243b34df3f8b407336969610f828773ee10c14fff6c04f653eaf25dbb62c4/sqlc-dev/sqlc/issues/2398 |
| og:image:alt | Version 1.18.0 What happened? There seems to be a minor bug in checking ambiguous references when joning tables while using alias. To reproduce, change the sqlc/internal/endtoend/testdata/order_by_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Stumble |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width