From 759e00c2fa9080d8f2fbce6191f8a3fbd37c6ce3 Mon Sep 17 00:00:00 2001 From: xixi Date: Fri, 14 Aug 2020 14:42:29 +0800 Subject: [PATCH] types: nil/null should be regarded as value instead of type (#19157) --- types/datum.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/types/datum.go b/types/datum.go index c3eafbd9f3..610e01f92a 100644 --- a/types/datum.go +++ b/types/datum.go @@ -430,9 +430,11 @@ func (d *Datum) GetValue() interface{} { // SetValueWithDefaultCollation sets any kind of value. func (d *Datum) SetValueWithDefaultCollation(val interface{}) { - switch x := val.(type) { - case nil: + if val == nil { d.SetNull() + return + } + switch x := val.(type) { case bool: if x { d.SetInt64(1) @@ -478,9 +480,11 @@ func (d *Datum) SetValueWithDefaultCollation(val interface{}) { // SetValue sets any kind of value. func (d *Datum) SetValue(val interface{}, tp *types.FieldType) { - switch x := val.(type) { - case nil: + if val == nil { d.SetNull() + return + } + switch x := val.(type) { case bool: if x { d.SetInt64(1)