GORM Playground Link
https://go.dev/play/p/qkJo3hCfVBN The link above is created to appease the bot.
https://github.com/go-gorm/playground/pull/1
Description
After updating to the latest GORM yesterday, I am having this error on my email field which looks like this:
type User struct {
ApplicationModel
Email string `gorm:"not null;uniqueIndex,length:200" json:"email" validate:"required,email"`
.... other fields ....
}
This field should be a varchar(200).
Here is the error message: panic: Error 1170: BLOB/TEXT column 'email' used in key specification without a key length [recovered] panic: Error 1170: BLOB/TEXT column 'email' used in key specification without a key length
I can also that these two fields have different data types in the Database even though they have been defined identically except for the semi colon between not null and size
FirstName string `gorm:"not null;size:30" json:"firstName" validate:"required,lt=30"`
LastName string `gorm:"not null,size:30" json:"lastName" validate:"required,lt=30"`
First Name is a varchar with length 30 and Lastname is a long text.
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: a631807682
This field should be a varchar(200).
type User struct {
ApplicationModel
- Email string `gorm:"not null;uniqueIndex,length:200" json:"email" validate:"required,email"`
+ Email string `gorm:"not null;uniqueIndex;size:200" json:"email" validate:"required,email"`
.... other fields ....
}
First Name is a varchar with length 30 and Lastname is a long text.
FirstName string `gorm:"not null;size:30" json:"firstName" validate:"required,lt=30"`
- LastName string `gorm:"not null,size:30" json:"lastName" validate:"required,lt=30"`
+ LastName string `gorm:"not null;size:30" json:"lastName" validate:"required,lt=30"`