mirror of https://github.com/go-gorm/gorm.git
Marshal invalid DeletedAt as null, fix #3693
This commit is contained in:
parent
a8141b6cc9
commit
3ebdcbdb18
|
@ -26,8 +26,11 @@ func (n DeletedAt) Value() (driver.Value, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n DeletedAt) MarshalJSON() ([]byte, error) {
|
func (n DeletedAt) MarshalJSON() ([]byte, error) {
|
||||||
|
if n.Valid {
|
||||||
return json.Marshal(n.Time)
|
return json.Marshal(n.Time)
|
||||||
}
|
}
|
||||||
|
return json.Marshal(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (n *DeletedAt) UnmarshalJSON(b []byte) error {
|
func (n *DeletedAt) UnmarshalJSON(b []byte) error {
|
||||||
err := json.Unmarshal(b, &n.Time)
|
err := json.Unmarshal(b, &n.Time)
|
||||||
|
|
Loading…
Reference in New Issue