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,7 +26,10 @@ 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 {
|
||||||
|
|
Loading…
Reference in New Issue