Closed lvxin1986 closed 5 years ago
I believe it's not a bug but the expected behaviour. For example, MySQL does not use the boolean
type but the tinyint
one to identify the booleans variables (only 0 and 1 values). Boolean is a synonym of tinyint. Postgres has boolean type. From your comment, I believe you are using MySQL (from InnoDB at least), so that's not a bug.
type K8sCluster struct { gorm.Model ApiAddr string
gorm:"type:varchar(20);not null;index:clusterApiAddr_idx"
LoginUser stringgorm:"type:varchar(16);not null"
LoginPasswd stringgorm:"type:varchar(32);not null"
Tag stringgorm:"type:varchar(16);unique"
TailDomain stringgorm:"type:varchar(64);"
InSecure boolgorm:"type:boolean;"
} if !db.HasTable(&K8sCluster{}) { if err := db.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8").CreateTable(&K8sCluster{}).Error; err != nil { panic(err) } } the field InSecure is boolean but gorm convert this file to tinyint I think is a bug