Skip to content
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

Gorm Optional Struct tags #38

Closed
shrhawk-entertainer opened this issue Apr 2, 2020 · 7 comments
Closed

Gorm Optional Struct tags #38

shrhawk-entertainer opened this issue Apr 2, 2020 · 7 comments

Comments

@shrhawk-entertainer
Copy link

Does this package support gorm optional structs tags such as Size, PRIMARY_KEY, AUTO_INCREMENT?
https://gorm.io/docs/models.html#Supported-Struct-tags

type Batch struct {
	ID          int            `gorm:"column:id;primary_key" json:"id"`
	Title       string         `gorm:"column:title" json:"title"`
	Description sql.NullString `gorm:"column:description" json:"description"`
	UrlsCount   int            `gorm:"column:urls_count" json:"urls_count"`
	CreatedAt   time.Time      `gorm:"column:created_at" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at" json:"updated_at"`
}

above struct was created with following command but no optional struct tags
gen --connstr "USER:PASSWORD@tcp(127.0.0.1:3306)/dbname" --database dbname --table batches --gorm --json

@smallnest
Copy link
Owner

No. Theoretically it can support mysql by querying mysql schema table but actually it support databases in a common mannner (database/sql) and can't fetch those info.

@alexj212
Copy link
Collaborator

alexj212 commented May 1, 2020

@shrhawk-entertainer This has been updated with the latest release. Mysql db specifics are queried from the db to populate nullable, auto increment and primary key for gorm annotations

@shrhawk-entertainer
Copy link
Author

@alexj212 that's excellent work but how to disable dao creation? and it's better if we remove .gitignore and README.MD files

@shrhawk-entertainer
Copy link
Author

also @alexj212 can you add Size tag?

@alexj212
Copy link
Collaborator

alexj212 commented May 2, 2020

@shrhawk-entertainer Size tag has been added with meta data probe to get the length of varchar, char, and text fields. Also added options --generate-dao and --generate-proj

@shrhawk-entertainer
Copy link
Author

@alexj212 will you support default values?

@alexj212
Copy link
Collaborator

supported in v0.9 release coming shortly - functions such as now() are ignored, constant values are added to gorm tags.

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

No branches or pull requests

3 participants