From 88a0888d6d897ffd0e033275839b6f5b10624198 Mon Sep 17 00:00:00 2001 From: haolei Date: Sun, 26 Jul 2015 00:01:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=94=AF=E6=8C=81sql.NullStr?= =?UTF-8?q?ing...=E6=97=B6AllCols()=E6=97=B6=E6=B2=A1=E6=9C=89=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=A9=BA=E5=AD=97=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- statement.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/statement.go b/statement.go index 56c0471f..6919b6c5 100644 --- a/statement.go +++ b/statement.go @@ -220,6 +220,7 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{}, requiredField := useAllCols includeNil := useAllCols lColName := strings.ToLower(col.Name) + if b, ok := mustColumnMap[lColName]; ok { if b { requiredField = true @@ -321,10 +322,8 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{}, continue } val = engine.FormatTime(col.SQLType.Name, t) - } else if nulVal, ok := fieldValue.Interface().(driver.Valuer); ok { - if val, _ = nulVal.Value(); val == nil { - continue - } + } else if nulType, ok := fieldValue.Interface().(driver.Valuer); ok { + val, _ = nulType.Value() } else { engine.autoMapType(fieldValue) if table, ok := engine.Tables[fieldValue.Type()]; ok {