sqlx
sqlx copied to clipboard
missing destination name scene_type in *[]*model.Resource
Issue description
I have a table named resource and have defined a struct for it. However, I now need to add a new field to the table, but when this field is not yet added to the struct definition in the code, running the code results in an error: "missing destination name scene_type in *[]*model.Resource." ,even though I didn't use this field . How can I avoid this error? Since database changes and code changes are not deployed simultaneously, this could cause issues when the service goes live.
Example code
type Resource struct {
Id int `db:"id" json:"id"`
CompanyId int `db:"company_id" json:"companyId"`
Pid int `db:"pid" json:"pid"`
CreatorId int `db:"creator_id" json:"creatorId"`
Size int64 `db:"size" json:"size"`
Width int `db:"width" json:"width"`
Height int `db:"height" json:"height"`
IsFolder bool `db:"is_folder" json:"isFolder"`
Trashed bool `db:"trashed" json:"trashed"`
Type ResourceType `db:"type" json:"type"`
Filename string `db:"filename" json:"filename"`
Extension string `db:"extension" json:"extension"`
Thumbnail string `db:"thumbnail" json:"thumbnail"`
// SceneType int `db:"scene_type" json:"sceneType"` //if I not add this it will be error,even though I didn't use this field
}
Error log
missing destination name scene_type in *[]*model.Resource