Fix Postgres query handling null values for smallint (#36648)

* Fix Postgres query handling null values for smallint

* Fix converting to int16
This commit is contained in:
idafurjes
2021-07-13 09:36:24 +02:00
committed by GitHub
parent c26bd6c52f
commit 5d01add7da
2 changed files with 28 additions and 5 deletions

View File

@ -200,5 +200,25 @@ func (t *postgresQueryResultTransformer) GetConverterList() []sqlutil.StringConv
},
},
},
{
Name: "handle INT2",
InputScanKind: reflect.Interface,
InputTypeName: "INT2",
ConversionFunc: func(in *string) (*string, error) { return in, nil },
Replacer: &sqlutil.StringFieldReplacer{
OutputFieldType: data.FieldTypeNullableInt16,
ReplaceFunc: func(in *string) (interface{}, error) {
if in == nil {
return nil, nil
}
i64, err := strconv.ParseInt(*in, 10, 16)
if err != nil {
return nil, err
}
v := int16(i64)
return &v, nil
},
},
},
}
}