Marshalling zero valued Deleted at to nullhttps://github.com/go-gorm/gorm/issues/3693 (#3695)
This commit is contained in:
parent
3ebdcbdb18
commit
57b033e2dd
@ -33,8 +33,12 @@ func (n DeletedAt) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *DeletedAt) UnmarshalJSON(b []byte) error {
|
func (n *DeletedAt) UnmarshalJSON(b []byte) error {
|
||||||
|
if string(b) == "null" {
|
||||||
|
n.Valid = false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
err := json.Unmarshal(b, &n.Time)
|
err := json.Unmarshal(b, &n.Time)
|
||||||
if err == nil && !n.Time.IsZero() {
|
if err == nil {
|
||||||
n.Valid = true
|
n.Valid = true
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user