使用 xorm/cmd 进行 reverse 生成 go orm 模型,datetime 默认值无效 #76

Open
opened 2019-10-30 00:59:54 +00:00 by conero · 0 comments
  • xorm v0.8.0

使用 xorm/cmd 进行 reverse 生成 go orm 模型,datetime 默认值无效

手动修改后正常。    
// 用户表信息
type User struct {
	Id       int       `xorm:"not null pk autoincr comment('数据id') INT(11)"`
	//Mtime    time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('注册时间') DATETIME"`
	Mtime      time.Time `xorm:"created"`
}

// 新增数据出错,默认值无效!
user := new(model.User)

ctt, er := db.Insert(user)
if er == nil && ctt > 0 {
    // ...
} else {
    if er != nil {
        lgger.Errorf("admin设置时,新增数据错误: %v", er.Error())
    }
}
// [ERRO] 2019/10/29 23:25 admin设置时,新增数据错误: Error 1292: Incorrect datetime value: '' for column 'mtime' at row 1
- [x] xorm `v0.8.0` **使用 `xorm/cmd` 进行 `reverse` 生成 `go orm` 模型,datetime 默认值无效** 手动修改后正常。 ```go // 用户表信息 type User struct { Id int `xorm:"not null pk autoincr comment('数据id') INT(11)"` //Mtime time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('注册时间') DATETIME"` Mtime time.Time `xorm:"created"` } // 新增数据出错,默认值无效! user := new(model.User) ctt, er := db.Insert(user) if er == nil && ctt > 0 { // ... } else { if er != nil { lgger.Errorf("admin设置时,新增数据错误: %v", er.Error()) } } // [ERRO] 2019/10/29 23:25 admin设置时,新增数据错误: Error 1292: Incorrect datetime value: '' for column 'mtime' at row 1 ```
lunny added the
bug
label 2019-10-30 06:21:49 +00:00
This repo is archived. You cannot comment on issues.
No Milestone
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/cmd#76
No description provided.