Obtaining below the error
on batch insert os records using GORM for MSSQL
reflect: call of reflect.Value.Interface on zero Value
var users = []User{{Name: "jinzhu1"}, {Name: "jinzhu2"}, {Name: "jinzhu3"}}
DB.Create(&users)
for _, user := range users {
user.ID // 1,2,3
}
Obtaining db table not found error: mssql: Invalid object name 'dbo.at_' for below
DB.Model(&User{}).Create(map[string]interface{}{
"Name": "jinzhu", "Age": 18,
})
// batch insert from `[]map[string]interface{}{}`
DB.Model(&User{}).Create([]map[string]interface{}{
{"Name": "jinzhu_1", "Age": 18},
{"Name": "jinzhu_2", "Age": 20},
})
I met a same problem:
panic in handler: reflect: call of reflect.Value.Interface on zero Value
and I solved it by upgrading gorm to v2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.