types: nil/null should be regarded as value instead of type (#19157)

This commit is contained in:
xixi
2020-08-14 14:42:29 +08:00
committed by GitHub
parent 030eab2bca
commit 759e00c2fa

View File

@ -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)