You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far, I'm benefiting a lot from this package, so thank you for the excellent work so far.
I mentioned this in #26 but this seems to merit its own issue.
In my REST API, I accept PATCH requests, which have all optional fields, so that you can update only what you'd like to:
typeUpdateNewsRequeststruct {
Title null.StringDescription null.String
}
typeNewsstruct {
IDuintTitlestringDescriptionstring
}
I'm converting it like so:
httpModel:=UpdateNewsRequest {
Title: null.StringFrom("new title")
}
dbModel:=DatabaseModel {
// fields...Title: "old title"Description: "leave me alone"
}
iferr:=deepcopier.Copy(&httpModel).To(&dbModel); err!=nil {
t.Fatalf("Could not deep copy: %s", err)
}
assert.Equal(t, httpModel.Title.ValueOrZero(), dbModel.Title)
assert.Equal(t, "leave me alone", dbModel.Description)
This currently fails at the first assertion, because deepcopier did not copy UpdateNewsRequest.Title, presumably because it is a null.String and deepcopier does not understand it.
I'm wondering how much work it would be to integrate this optional update feature, I'll have to look at the codebase and see if I can implement this. Alternatively, if there is a way using the context feature to accomplish this, that would be wonderful, but I don't exactly understand what the context feature does from trying it out.
The text was updated successfully, but these errors were encountered:
So far, I'm benefiting a lot from this package, so thank you for the excellent work so far.
I mentioned this in #26 but this seems to merit its own issue.
In my REST API, I accept
PATCH
requests, which have all optional fields, so that you can update only what you'd like to:I'm converting it like so:
This currently fails at the first assertion, because
deepcopier
did not copyUpdateNewsRequest.Title
, presumably because it is anull.String
anddeepcopier
does not understand it.I'm wondering how much work it would be to integrate this optional update feature, I'll have to look at the codebase and see if I can implement this. Alternatively, if there is a way using the context feature to accomplish this, that would be wonderful, but I don't exactly understand what the context feature does from trying it out.
The text was updated successfully, but these errors were encountered: