Title: Functions returning `TABLE` types do not work · Issue #1322 · sqlc-dev/sqlc · GitHub
Open Graph Title: Functions returning `TABLE` types do not work · Issue #1322 · sqlc-dev/sqlc
X Title: Functions returning `TABLE` types do not work · Issue #1322 · sqlc-dev/sqlc
Description: Version 1.11.0 What happened? When a function returns a TABLE type, you get an "empty list" error or something like that. I'm sorry I saw this earlier today and don't have the exact output, but the repro below should work. sqlc generate ...
Open Graph Description: Version 1.11.0 What happened? When a function returns a TABLE type, you get an "empty list" error or something like that. I'm sorry I saw this earlier today and don't have the exact output, but the...
X Description: Version 1.11.0 What happened? When a function returns a TABLE type, you get an "empty list" error or something like that. I'm sorry I saw this earlier today and don't have the exa...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/1322
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Functions returning `TABLE` types do not work","articleBody":"### Version\r\n\r\n1.11.0\r\n\r\n### What happened?\r\n\r\nWhen a function returns a `TABLE` type, you get an \"empty list\" error or something like that. I'm sorry I saw this earlier today and don't have the exact output, but the repro below should work.\r\n\r\n`sqlc generate` fails due to an error.\r\n\r\n### Relevant log output\r\n\r\n_No response_\r\n\r\n### Database schema\r\n\r\n```sql\r\nCREATE TABLE accounts (\r\n id INTEGER GENERATED ALWAYS AS IDENTITY PRIMAR KEY,\r\n username TEXT NOT NULL UNIQUE,\r\n password TEXT NOT NULL\r\n);\r\n\r\n-- this is a useless and horrifying function cause we don't hash\r\n-- the password, this is just to repro the bug in sqlc\r\nCREATE OR REPLACE FUNCTION register_account(\r\n _username TEXT,\r\n _password VARCHAR(70)\r\n)\r\nRETURNS TABLE (\r\n account_id INTEGER\r\n)\r\nAS $$\r\nBEGIN\r\n INSERT INTO accounts (username, password)\r\n VALUES (\r\n _username,\r\n _password\r\n )\r\n RETURNING id INTO account_id;\r\n\r\n RETURN NEXT;\r\nEND;\r\n$$ LANGUAGE plpgsql;\r\n```\r\n\r\n\r\n### SQL queries\r\n\r\n```sql\r\n-- name: Foo :one\r\nSELECT * FROM register_account('a', 'b');\r\n```\r\n\r\n\r\n### Configuration\r\n\r\n_No response_\r\n\r\n### Playground URL\r\n\r\n_No response_\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/mitchellh","@type":"Person","name":"mitchellh"},"datePublished":"2021-12-01T00:58:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1322/sqlc/issues/1322"}
| 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:64230598-609b-f7d7-f623-c91ab5eb185e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0E2:371DAA:BB5B5D:BED054:6A5127D9 |
| html-safe-nonce | a4bc9a5445a129eb744aae65b74f3a6566676841fe19b1e4bf1ea45266d6d676 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEUyOjM3MURBQTpCQjVCNUQ6QkVEMDU0OjZBNTEyN0Q5IiwidmlzaXRvcl9pZCI6IjI3NjY3OTY4MDY5MjI3NzQ0ODkiLCJyZWdpb25fZWRnZSI6InNlYSIsInJlZ2lvbl9yZW5kZXIiOiJzZWEifQ== |
| visitor-hmac | fdb77d87240585d17a880f325a080b2e7f96c3be999707081ded9515b530ebfe |
| hovercard-subject-tag | issue:1067828822 |
| 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/1322/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b3111aefa215bbe008558d4dfaa36f1d2122b99553fc0afea0b15e6e80b7243/sqlc-dev/sqlc/issues/1322 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b3111aefa215bbe008558d4dfaa36f1d2122b99553fc0afea0b15e6e80b7243/sqlc-dev/sqlc/issues/1322 |
| og:image:alt | Version 1.11.0 What happened? When a function returns a TABLE type, you get an "empty list" error or something like that. I'm sorry I saw this earlier today and don't have the exact output, but the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mitchellh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 689b683944b0d7f015d0e776452c970832fa81b82dc15284469b556ecced715b |
| 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 | 942b51ed3bd5feee3d5e2719f890a5fe286edbbb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width