Title: Multiple CTE Update · Issue #1916 · sqlc-dev/sqlc · GitHub
Open Graph Title: Multiple CTE Update · Issue #1916 · sqlc-dev/sqlc
X Title: Multiple CTE Update · Issue #1916 · sqlc-dev/sqlc
Description: Version 1.15.0 What happened? Hi i Have This issue with the following query, i tested the query itself, and it works fine, but sqlc is giving me the below error. Relevant log output # package db db/query/user_address.sql:88:5: column "de...
Open Graph Description: Version 1.15.0 What happened? Hi i Have This issue with the following query, i tested the query itself, and it works fine, but sqlc is giving me the below error. Relevant log output # package db db...
X Description: Version 1.15.0 What happened? Hi i Have This issue with the following query, i tested the query itself, and it works fine, but sqlc is giving me the below error. Relevant log output # package db db...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1916
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multiple CTE Update","articleBody":"### Version\r\n\r\n1.15.0\r\n\r\n### What happened?\r\n\r\nHi \r\n\r\ni Have This issue with the following query, i tested the query itself, and it works fine, but sqlc is giving me the below error.\r\n\r\n### Relevant log output\r\n\r\n```shell\r\n# package db\r\ndb/query/user_address.sql:88:5: column \"default_address\" does not exist\r\n```\r\n\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TABLE \"user\" (\r\n \"id\" bigserial PRIMARY KEY NOT NULL,\r\n \"username\" varchar NOT NULL,\r\n \"email\" varchar UNIQUE NOT NULL,\r\n \"password\" varchar NOT NULL,\r\n \"telephone\" int NOT NULL DEFAULT 0,\r\n \"default_payment\" bigint,\r\n \"created_at\" timestamptz NOT NULL DEFAULT (now()),\r\n \"updated_at\" timestamptz NOT NULL DEFAULT '0001-01-01 00:00:00Z'\r\n);\r\n\r\nCREATE TABLE \"address\" (\r\n \"id\" bigserial PRIMARY KEY NOT NULL,\r\n \"address_line\" varchar NOT NULL,\r\n \"region\" varchar NOT NULL,\r\n \"city\" varchar NOT NULL,\r\n \"created_at\" timestamptz NOT NULL DEFAULT (now()),\r\n \"updated_at\" timestamptz NOT NULL DEFAULT '0001-01-01 00:00:00Z'\r\n);\r\n\r\nCREATE TABLE \"user_address\" (\r\n \"user_id\" bigint NOT NULL,\r\n \"address_id\" bigint UNIQUE NOT NULL,\r\n \"default_address\" bigint,\r\n \"created_at\" timestamptz NOT NULL DEFAULT (now()),\r\n \"updated_at\" timestamptz NOT NULL DEFAULT '0001-01-01 00:00:00Z'\r\n);\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: UpdateUserAddressWithAddress :one\r\nWITH t1 AS (\r\n UPDATE \"address\" as a\r\n SET\r\n address_line = COALESCE(sqlc.narg(address_line),address_line), \r\n region = COALESCE(sqlc.narg(region),region), \r\n city= COALESCE(sqlc.narg(city),city)\r\n WHERE id = COALESCE(sqlc.arg(id),id)\r\n RETURNING a.id, a.address_line, a.region, a.city\r\n ),\r\n \r\n t2 AS (\r\n UPDATE \"user_address\"\r\n SET\r\n default_address = COALESCE(sqlc.narg(default_address),default_address)\r\n WHERE\r\n user_id = COALESCE(sqlc.arg(user_id),user_id)\r\n AND address_id = COALESCE(sqlc.arg(address_id),address_id)\r\n RETURNING user_id, address_id, default_address\r\n\t)\r\n\t\r\nSELECT \r\nuser_id,\r\naddress_id,\r\ndefault_address,\r\naddress_line,\r\nregion,\r\ncity From t1,t2;\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n```yaml\r\nversion: 1\r\npackages:\r\n - name: \"db\"\r\n path: \"./db/sqlc\"\r\n queries: \"./db/query/\"\r\n schema: \"./db/migration/\"\r\n engine: \"postgresql\"\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\r\n```\r\n\r\n\r\n### Playground URL\r\n\r\nhttps://play.sqlc.dev/p/17faf82c923406a0c8272595305c3262ea1e0e74c744a0d3744e3ebb23554cc9\r\n\r\n### What operating system are you using?\r\n\r\nLinux\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/DarkHeros09","@type":"Person","name":"DarkHeros09"},"datePublished":"2022-10-27T21:44:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/1916/sqlc/issues/1916"}
| 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:898c82c3-9e9e-5317-6d19-a9f3ff986218 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1F2:1F29:227A5D5:2ECFA30:6A5056E3 |
| html-safe-nonce | b074bf780236f67022aa75c9a6b977f5509a9859940efdb9e4f8ff20449a1b64 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUYyOjFGMjk6MjI3QTVENToyRUNGQTMwOjZBNTA1NkUzIiwidmlzaXRvcl9pZCI6IjE3NjI5MTMzMTc0ODE4OTU2NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5431c303312b77b0cf1ae03e7e9860e5918b0dc54ac2a32ef2ff7879a7542b54 |
| hovercard-subject-tag | issue:1426300285 |
| 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/1916/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8062ba0d1a2c581525dd89bce4cb346885f8f0e9272a1c173ac97b9e6e2c9259/sqlc-dev/sqlc/issues/1916 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8062ba0d1a2c581525dd89bce4cb346885f8f0e9272a1c173ac97b9e6e2c9259/sqlc-dev/sqlc/issues/1916 |
| og:image:alt | Version 1.15.0 What happened? Hi i Have This issue with the following query, i tested the query itself, and it works fine, but sqlc is giving me the below error. Relevant log output # package db db... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DarkHeros09 |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width