Title: sqlc hallucinates ambiguous column references when no ambiguity exists · Issue #2538 · sqlc-dev/sqlc · GitHub
Open Graph Title: sqlc hallucinates ambiguous column references when no ambiguity exists · Issue #2538 · sqlc-dev/sqlc
X Title: sqlc hallucinates ambiguous column references when no ambiguity exists · Issue #2538 · sqlc-dev/sqlc
Description: Version 1.19.1 What happened? Discovered while working on #2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below. To fix we'll need to update findColumnForRef() in output_col...
Open Graph Description: Version 1.19.1 What happened? Discovered while working on #2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below. To fix we'll need to...
X Description: Version 1.19.1 What happened? Discovered while working on #2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below. To fix we'll nee...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2538
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlc hallucinates ambiguous column references when no ambiguity exists ","articleBody":"### Version\n\n1.19.1\n\n### What happened?\n\nDiscovered while working on https://github.com/sqlc-dev/sqlc/pull/2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below.\r\n\r\nTo fix we'll need to update `findColumnForRef()` in `output_columns.go` I believe.\n\n### Relevant log output\n\n```shell\nquery.sql:9:1: column reference \"name\" 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 BIGSERIAL PRIMARY KEY,\r\n name text NOT NULL,\r\n bio text\r\n);\n```\n\n\n### SQL queries\n\n```sql\nSELECT a.name\r\nFROM authors a JOIN authors b ON a.id = b.id\r\nORDER BY name;\r\n\r\nSELECT a.name AS name\r\nFROM authors a JOIN authors b ON a.id = b.id\r\nORDER BY name;\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/8e9c3fa8f50201433c489b118a731130a7011574ec53d27bbe460eb1978f2f13\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/andrewmbenton","@type":"Person","name":"andrewmbenton"},"datePublished":"2023-07-27T21:56:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2538/sqlc/issues/2538"}
| 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:a955e7ef-a538-0552-7e7e-9241e23df327 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D96:1B4753:A9D79D:E7091C:6A5206D2 |
| html-safe-nonce | c83cd7d75c05c40b3182c9510aac45100ad94972389b0cd6469d5e269cc2a26f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDk2OjFCNDc1MzpBOUQ3OUQ6RTcwOTFDOjZBNTIwNkQyIiwidmlzaXRvcl9pZCI6IjQ0ODc1NDkzNDkyNTQwMDY0ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c88a9e4870b9402a950637b13a203c8dc362127a5c05a678ae5edde54294213b |
| hovercard-subject-tag | issue:1825277904 |
| 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/2538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/607fccda19f6c4b404dadbd674328a8e554a87068faeb8b0886ad09768735fbb/sqlc-dev/sqlc/issues/2538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/607fccda19f6c4b404dadbd674328a8e554a87068faeb8b0886ad09768735fbb/sqlc-dev/sqlc/issues/2538 |
| og:image:alt | Version 1.19.1 What happened? Discovered while working on #2537, sqlc returns an ambiguous column reference error for some queries which run fine with psql. See examples below. To fix we'll need to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andrewmbenton |
| 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