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)