mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 06:42:21 +08:00
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:
@ -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
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user