要通过struct更新,可以通过SELECT指定空值字段
但是如何指定子结构体的空字段呢
type A struct{
Id int64 `gorm:"column:id"`
Name string `gorm:"column:name"`
Extra B `gorm:"foreignkey:Aid;references:Id;"`
}
type B struct{
Aid int64 `gorm:"column:a_id"`
Title string `gorm:"column:title"`
}
数据格式:
data:={
Id:2,
Name:"张三",
Extra:{
Title:""
}
}
db.Select([]string{"Name","Extra"}).updates(&data)
这是无法更新B的数据 请问这应该如何处理
The document you expected this should be explained
Expected answer
Comment From: jinzhu
We won't update associations to blank ,even it is selected. for normal fields it should works.
What's your situations for the issue?