Mainly I’ve this desk:
sort Desk struct {
Username `gorm:"column:username;sort:textual content;examine:username>=3;examine:username<=20;distinctive;not null"`
}
My purpose is for Username to fulfill this situation:username >= 3 && username <= 20
However after I run this:
information := Desk{Username: "aValidUsername"}
err := db.Debug().Mannequin(&information).Save(information).Error
I get this error:constraint failed: CHECK constraint failed: chk_table_username (275)
Which makes me assume my tag is mistaken. What’s the appropriate approach to do it?
I already discovered the reply::
sort Desk struct {
Username string `gorm:"column:username;sort:textual content;examine:size(username)>=3;examine:size(username)<=20;distinctive;not null"`
}