We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
目标表结构
CREATE TABLE `test` ( `id` INT ( 11 ) AUTO_INCREMENT NOT NULL, `name` VARCHAR ( 20 ) NULL DEFAULT NULL, `resp_time` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY ( `id` ))
golang 结构体
type Test struct { ID int `gorm:"autoIncrement:true;primaryKey;column:id;type:int(11);not null" json:"id"` Name string `gorm:"column:name;type:varchar(20);not null;default:''" json:"name"` RespTime *time.Time `gorm:"column:resp_time;type:timestamp;default:null" json:"resp_time"` //RespTime *time.Time `gorm:"column:resp_time;type:timestamp" json:"resp_time"` //RespTime time.Time `gorm:"column:resp_time;type:timestamp;default:null" json:"resp_time"` }
gorm 生成的表结构创建语句:
CREATE TABLE `test` ( `id` INT ( 11 ) AUTO_INCREMENT NOT NULL, `name` VARCHAR ( 20 ) NULL DEFAULT NULL, `resp_time` TIMESTAMP DEFAULT NULL, PRIMARY KEY ( `id` ))
执行报错:
Error 1067 (42000): Invalid default value for 'resp_time'
期望的 SQL 为: resp_time TIMESTAMP NULL DEFAULT NULL gorm 生成的 SQL 为:resp_time TIMESTAMP DEFAULT NULL
resp_time
Issue#7127
The text was updated successfully, but these errors were encountered:
jinzhu
No branches or pull requests
Your Question
目标表结构
golang 结构体
gorm 生成的表结构创建语句:
执行报错:
Error 1067 (42000): Invalid default value for 'resp_time'
Expected answer
期望的 SQL 为:
resp_time
TIMESTAMP NULL DEFAULT NULLgorm 生成的 SQL 为:
resp_time
TIMESTAMP DEFAULT NULLIssue#7127
The text was updated successfully, but these errors were encountered: