[MYSQL] convert explicitely smallint and tinyint (#35897)

* [MYSQL] convert explicitely smallint and tinyint

* clean up code

* fix comments
This commit is contained in:
ying-jeanne
2021-06-22 00:10:45 +08:00
committed by GitHub
parent bef0f797ab
commit 73fdd9dc22
2 changed files with 94 additions and 2 deletions

View File

@ -265,6 +265,44 @@ func (t *mysqlQueryResultTransformer) GetConverterList() []sqlutil.StringConvert
},
},
},
{
Name: "handle TINYINT",
InputScanKind: reflect.Struct,
InputTypeName: "TINYINT",
ConversionFunc: func(in *string) (*string, error) { return in, nil },
Replacer: &sqlutil.StringFieldReplacer{
OutputFieldType: data.FieldTypeNullableInt64,
ReplaceFunc: func(in *string) (interface{}, error) {
if in == nil {
return nil, nil
}
v, err := strconv.ParseInt(*in, 10, 64)
if err != nil {
return nil, err
}
return &v, nil
},
},
},
{
Name: "handle SMALLINT",
InputScanKind: reflect.Struct,
InputTypeName: "SMALLINT",
ConversionFunc: func(in *string) (*string, error) { return in, nil },
Replacer: &sqlutil.StringFieldReplacer{
OutputFieldType: data.FieldTypeNullableInt64,
ReplaceFunc: func(in *string) (interface{}, error) {
if in == nil {
return nil, nil
}
v, err := strconv.ParseInt(*in, 10, 64)
if err != nil {
return nil, err
}
return &v, nil
},
},
},
{
Name: "handle INT",
InputScanKind: reflect.Struct,