Marshal invalid DeletedAt as null, fix #3693

This commit is contained in:
Jinzhu 2020-10-30 19:08:20 +08:00
parent a8141b6cc9
commit 3ebdcbdb18
1 changed files with 4 additions and 1 deletions

View File

@ -26,7 +26,10 @@ func (n DeletedAt) Value() (driver.Value, error) {
}
func (n DeletedAt) MarshalJSON() ([]byte, error) {
if n.Valid {
return json.Marshal(n.Time)
}
return json.Marshal(nil)
}
func (n *DeletedAt) UnmarshalJSON(b []byte) error {