go-gorm/gorm.io

Custom check constraint name doesn't allow numbers or special character

PBholewasi opened this issue · 0 comments

Document Link

Your Question

The below name is allowed :
type Patient struct {
ID string json:"id" gorm:"primaryKey;column:id;"
Name string json:"name" gorm:"column:name"
Age int json:"age" gorm:"check:'chk_age_nine',age>99;column:age"
Gender string json:"gender" gorm:"column:gender"
CreatedAt int // Set to current time if it is zero on creating
UpdatedAt int // Set to current unix seconds on updating or if it is zero on creating
Deleted gorm.DeletedAt
}

Expected answer

The below name throws error :
type Patient struct {
ID string json:"id" gorm:"primaryKey;column:id;"
Name string json:"name" gorm:"column:name"
Age int json:"age" gorm:"check:'chk_age_99',age>99;column:age"
Gender string json:"gender" gorm:"column:gender"
CreatedAt int // Set to current time if it is zero on creating
UpdatedAt int // Set to current unix seconds on updating or if it is zero on creating
Deleted gorm.DeletedAt
}