Title: Add support for custom struct tags · Issue #534 · sqlc-dev/sqlc · GitHub
Open Graph Title: Add support for custom struct tags · Issue #534 · sqlc-dev/sqlc
X Title: Add support for custom struct tags · Issue #534 · sqlc-dev/sqlc
Description: When working with structs, struct tags are used to add additional information to a field. This is for example very common when using validation packages. But currently there is no way to add additional struct tags to take advantage of th...
Open Graph Description: When working with structs, struct tags are used to add additional information to a field. This is for example very common when using validation packages. But currently there is no way to add additi...
X Description: When working with structs, struct tags are used to add additional information to a field. This is for example very common when using validation packages. But currently there is no way to add additi...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/534
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for custom struct tags","articleBody":"When working with structs, struct tags are used to add additional information to a field. This is for example very common when using validation packages. But currently there is no way to add additional struct tags to take advantage of this. \r\n\r\nI think it would be a great idea to add a comment syntax just like the `-- name:NameForQuery` for table columns. \r\n\r\nA possible option to express these custom struct tags would be to write create table statements like this:\r\n```sql\r\nCREATE TABLE user (\r\n id BIGSERIAL PRIMARY KEY,\r\n\r\n -- tags:`validate:\"min=10,max=0\"`\r\n username text NOT NULL,\r\n\r\n -- tags:`validate:\"gt=18\"`\r\n age integer NOT NULL,\r\n\r\n -- tags:`validate:\"url\"`\r\n website text NOT NULL\r\n);\r\n```\r\n\r\nor alternatively:\r\n```sql\r\nCREATE TABLE user (\r\n id BIGSERIAL PRIMARY KEY,\r\n username text NOT NULL, -- tags:`validate:\"min=10,max=0\"`\r\n age integer NOT NULL, -- tags:`validate:\"gt=18\"`\r\n website text NOT NULL -- tags:`validate:\"url\"`\r\n);\r\n```","author":{"url":"https://github.com/philippta","@type":"Person","name":"philippta"},"datePublished":"2020-06-05T11:32:20Z","url":"https://github.com/sqlc-dev/sqlc/issues/534"}
| 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:47b67b97-2759-eb75-0502-ca68b5303c5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8564:2652DC:2558051:2F951FD:6B017A73 |
| html-safe-nonce | 9d744b3b2558ceff4798ddea326c3129d4615538430e1d6a506bf023327bc41c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTY0OjI2NTJEQzoyNTU4MDUxOjJGOTUxRkQ6NkIwMTdBNzMiLCJ2aXNpdG9yX2lkIjoiMTgzNjk0NjIyMjgyNTQzNzgxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cee88310019fe08f7a8a339228338eb8011564783056e71164a4da34b133464b |
| hovercard-subject-tag | issue:631522899 |
| 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/534/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6aef35afa906da4f18f649896f5d7327dea5aba1d87f9119f51a474685c0e0e2/sqlc-dev/sqlc/issues/534 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6aef35afa906da4f18f649896f5d7327dea5aba1d87f9119f51a474685c0e0e2/sqlc-dev/sqlc/issues/534 |
| og:image:alt | When working with structs, struct tags are used to add additional information to a field. This is for example very common when using validation packages. But currently there is no way to add additi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | philippta |
| 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