From 06f4bf493d2099de0a6d73b77ec45a73a5ad4a7c Mon Sep 17 00:00:00 2001 From: JessonChan Date: Tue, 10 Jun 2014 22:10:58 +0800 Subject: [PATCH] ignore nil time --- orm/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/orm/db.go b/orm/db.go index b67a9bd5..d8301b75 100644 --- a/orm/db.go +++ b/orm/db.go @@ -144,7 +144,11 @@ func (d *dbBase) collectFieldValue(mi *modelInfo, fi *fieldInfo, ind reflect.Val value = field.Interface() if t, ok := value.(time.Time); ok { d.ins.TimeToDB(&t, tz) - value = t + if t.IsZero() { + value = nil + } else { + value = t + } } default: switch {