Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add custom tags #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

feat: add custom tags #1064

wants to merge 1 commit into from

Conversation

ymzuiku
Copy link

@ymzuiku ymzuiku commented Jun 27, 2021

sqlc is very perfect database model generation tool, we use sqlc and gorm(use dynamic query).
This pull request is extends use sql comment custom go struct tags it's style:

Schema example code in comment:

@<tagName>:<tagValue>

Examples:

Add comment in SQL(Postgres):

COMMENT ON COLUMN account.id is '@gorm:primaryKey @validate:required,min=3,max=32';

Generate go struct code:

type Account struct {
  ID  int32  `gorm:"primaryKey" json:"id" validate:"required,min=3,max=32"`
}

@kyleconroy
Copy link
Collaborator

@ymzuiku Thank you very much for taking the time to code up this feature. Sadly, I won't be accepting this PR. If we add support for custom fields on a per-column basis, I'd like to make the mechanism more general so that it can be applied to any database engine or language backend.

@kyleconroy kyleconroy closed this Jun 28, 2021
@imraan-go
Copy link

I'd like to make the mechanism more general so that it can be applied to any database engine or language backend.

Closing a PR just because he could not provide solution for all language and database engine is a bad idea. This feature was requested by many including me for Golang + Postgres. I think this PR should be merged so other developers are encouraged to provide support for other languages and database engines. These PR will solves the following issues:

#546
#534
jschaf/pggen#24

@imraan-go
Copy link

Also I'm not sure if other language has tag support like Golang?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants