nfjBill / gorm-driver-dm

达梦数据库gorm驱动
Apache License 2.0
19 stars 15 forks source link

migrate 创建表时报空指针异常 #2

Open ximenhaoziye opened 2 years ago

ximenhaoziye commented 2 years ago

表数据结构如下 type Department struct { Model

Name     string `json:"name" gorm:"index"`
ParentID *int   `json:"parent_id" gorm:"index"`
Level    int    `gorm:"default:0" json:"level"`

DeptCode string `json:"dept_code" gorm:"unique;index"`
Users        []User `gorm:"many2many:users_departments;" json:"-"`
DisplayOrder int `gorm:"default:0" json:"display_order"`

MXDeptID  int `json:"mx_dept_id"`
MXDeptPID int `json:"mx_dept_pid"`

}

jeyrce commented 2 years ago

我遇到一样的问题了,另外我fork了一份老哥的仓库,准备自己改改

go1223 commented 2 years ago

结构体用到的字段不能是达梦数据库的关键字,level好像就是,可以尝试用column进行列的重命名

jeyrce commented 2 years ago

@go1223 感谢,我去试试看

smilextay commented 9 months ago

@jeyrce 如果使用带cancel的context。执行的时候拿到的connect 是nil,所以panic