From bb8b2f6dc8271777dde959c04246a2a29ddd2278 Mon Sep 17 00:00:00 2001 From: venjiang Date: Fri, 21 Feb 2020 18:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9E=E7=8E=B0FromDB,ToDB=E6=96=B9?= =?UTF-8?q?=E6=B3=95,=E4=BD=BF=E7=94=A8=E6=8C=87=E9=92=88=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=B7=BB=E5=8A=A0/=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=A9=BA=E6=9B=B4=E6=96=B0,=E4=B8=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- session_convert.go | 5 ++++- statement.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/session_convert.go b/session_convert.go index 7f11354d..9009fadd 100644 --- a/session_convert.go +++ b/session_convert.go @@ -558,7 +558,10 @@ func (session *Session) value2Interface(col *core.Column, fieldValue reflect.Val if col.SQLType.IsBlob() { return data, nil } - return string(data), nil + if len(data) > 0 { + return string(data), nil + } + return nil, nil } fieldType := fieldValue.Type() diff --git a/statement.go b/statement.go index ea3ecabe..454accb7 100644 --- a/statement.go +++ b/statement.go @@ -330,6 +330,11 @@ func (statement *Statement) buildUpdates(bean interface{}, if err != nil { engine.logger.Error(err) } else { + if fieldType.Kind() == reflect.Ptr && len(data) == 0 { + args = append(args, nil) + colNames = append(colNames, fmt.Sprintf("%v=?", engine.Quote(col.Name))) + continue + } val = data } goto APPEND