Title: Support emitting accessor methods to enable Go interfaces? · Issue #2746 · sqlc-dev/sqlc · GitHub
Open Graph Title: Support emitting accessor methods to enable Go interfaces? · Issue #2746 · sqlc-dev/sqlc
X Title: Support emitting accessor methods to enable Go interfaces? · Issue #2746 · sqlc-dev/sqlc
Description: What do you want to change? It would sometimes be handy to be able to handle multiple database rows with common field names using some Go code which implements generic operations (for example, checking that a user token contains a group ...
Open Graph Description: What do you want to change? It would sometimes be handy to be able to handle multiple database rows with common field names using some Go code which implements generic operations (for example, chec...
X Description: What do you want to change? It would sometimes be handy to be able to handle multiple database rows with common field names using some Go code which implements generic operations (for example, chec...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/2746
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support emitting accessor methods to enable Go interfaces?","articleBody":"### What do you want to change?\r\n\r\nIt would sometimes be handy to be able to handle multiple database rows with common field names using some Go code which implements generic operations (for example, checking that a user token contains a group claim that matches the `group_id` of some database object).\r\n\r\nIt would be handy in these cases if the objects all implemented a `GetGroupID()` method, which could be used to match the types to an interface. For example:\r\n\r\n```golang\r\n\r\ntype List struct {\r\n ID int64 `json:\"id\"`\r\n GroupID int64 `json:\"group_id\"`\r\n}\r\n\r\nfunc (l List) GetID() int64 {\r\n return l.ID\r\n}\r\n\r\nfunc (l List) GetGroupID() int64 {\r\n return l.GroupID\r\n}\r\n```\r\n\r\nAnd then elsewhere (which would define the `database.GroupIDer` interface):\r\n\r\n```golang\r\nfunc IsAuthorized(claims []int64, obj database.GroupIDer) bool {\r\n return slices.Contains(claims, obj.GetGroupID())\r\n}\r\n```\r\n\r\n### What database engines need to be changed?\r\n\r\nNone\r\n\r\n### What programming language backends need to be changed?\r\n\r\nGo","author":{"url":"https://github.com/evankanderson","@type":"Person","name":"evankanderson"},"datePublished":"2023-09-20T00:53:02Z","url":"https://github.com/sqlc-dev/sqlc/issues/2746"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:27401d18-7c7f-38ae-e9b9-51d70b678e0a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95F6:1CCECA:113643:16DDA1:6B018B89 |
| html-safe-nonce | f34d6da1cc948d389791ac6f44d775a164c4af4e6d3590add232b4a079e94b64 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUY2OjFDQ0VDQToxMTM2NDM6MTZEREExOjZCMDE4Qjg5IiwidmlzaXRvcl9pZCI6IjI4MTUzMDk5NjU3ODEyMDc5NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b6f5d5fd9a8e7d4a54c38f20b65480eb44b5593d38d00e7563854be5a1124f39 |
| hovercard-subject-tag | issue:1903908348 |
| 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/2746/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aee91f2a00b3f1550140229d6204171e3b74bfb8a18b2bdfc399037db44327eb/sqlc-dev/sqlc/issues/2746 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aee91f2a00b3f1550140229d6204171e3b74bfb8a18b2bdfc399037db44327eb/sqlc-dev/sqlc/issues/2746 |
| og:image:alt | What do you want to change? It would sometimes be handy to be able to handle multiple database rows with common field names using some Go code which implements generic operations (for example, chec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | evankanderson |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width