Title: [proposal] `:map key=somefield` query annotation · Issue #2353 · sqlc-dev/sqlc · GitHub
Open Graph Title: [proposal] `:map key=somefield` query annotation · Issue #2353 · sqlc-dev/sqlc
X Title: [proposal] `:map key=somefield` query annotation · Issue #2353 · sqlc-dev/sqlc
Description: What do you want to change? I frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this: m := map[string]gendb.User{} users, err := gendb.QueryUsers(ctx) for _, u := range u...
Open Graph Description: What do you want to change? I frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this: m := map[string]gendb.User{} users, err := g...
X Description: What do you want to change? I frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this: m := map[string]gendb.User{} users, err := g...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2353
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[proposal] `:map key=somefield` query annotation","articleBody":"### What do you want to change?\n\nI frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this:\r\n\r\n```\r\nm := map[string]gendb.User{}\r\nusers, err := gendb.QueryUsers(ctx)\r\nfor _, u := range users {\r\n m[u.Username] = u\r\n}\r\n```\r\n\r\nI've been holding off on this feature request hoping that generics would cleanly solve this, but solutions with generics aren't as pretty as I'd hoped. (Using a Map plus a lambda to return a field.)\r\n\r\nGiven that sqlc has all the information needed for this, it would be a neat convenience if sqlc could generate this boilerplate for me :)\r\n\r\nI'm willing to send a PR if approved.\n\n### What database engines need to be changed?\n\n_No response_\n\n### What programming language backends need to be changed?\n\nGo","author":{"url":"https://github.com/Jille","@type":"Person","name":"Jille"},"datePublished":"2023-06-21T21:30:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2353/sqlc/issues/2353"}
| 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:a6288202-f7b1-2a88-0052-fe47a1959bcb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3B2:25E4BD:6C5CB4:91EC92:6A51F0F5 |
| html-safe-nonce | 289fc8cd403b570dff7ec0774fdd640382a53479542e85533e2fa113b147d600 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0IyOjI1RTRCRDo2QzVDQjQ6OTFFQzkyOjZBNTFGMEY1IiwidmlzaXRvcl9pZCI6IjUwMjU1MjY4Mjk1MTMwNDQyMTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5e710f24708d5eda1934e729a42bbb59626360a0e8ae43b64756d0c00a1e333b |
| hovercard-subject-tag | issue:1768521934 |
| 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/2353/issue_layout |
| twitter:image | https://opengraph.githubassets.com/234509451d1958c2108ac4272dd72e3a2cfb0471b4d38268dab32aae68d54cba/sqlc-dev/sqlc/issues/2353 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/234509451d1958c2108ac4272dd72e3a2cfb0471b4d38268dab32aae68d54cba/sqlc-dev/sqlc/issues/2353 |
| og:image:alt | What do you want to change? I frequently find myself converting the results from a query to a map, keyed by one of the fields. The code looks like this: m := map[string]gendb.User{} users, err := g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jille |
| 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