Tidying up

This commit is contained in:
Jason Fulghum
2023-09-20 11:21:18 -07:00
parent f9129e446c
commit e87f4ef67a

View File

@@ -144,18 +144,32 @@ func FromSqlType(sqlType sql.Type) (TypeInfo, error) {
switch queryType {
case sqltypes.Null:
return UnknownType, nil
case sqltypes.Int8, sqltypes.Int16, sqltypes.Int24, sqltypes.Int32, sqltypes.Int64:
case sqltypes.Int8:
// MySQL allows only the TINYINT type to have a display width, so it's the only
// integer type that needs to be checked for it's underlying NumberType data.
numberType, ok := sqlType.(sql.NumberType)
if !ok {
return nil, fmt.Errorf("expected sql.NumberType, but received: %T", sqlType)
}
return &intType{numberType}, nil
case sqltypes.Uint8, sqltypes.Uint16, sqltypes.Uint24, sqltypes.Uint32, sqltypes.Uint64:
numberType, ok := sqlType.(sql.NumberType)
if !ok {
return nil, fmt.Errorf("expected sql.NumberType, but received: %T", sqlType)
}
return &uintType{numberType}, nil
case sqltypes.Int16:
return Int16Type, nil
case sqltypes.Int24:
return Int24Type, nil
case sqltypes.Int32:
return Int32Type, nil
case sqltypes.Int64:
return Int64Type, nil
case sqltypes.Uint8:
return Uint8Type, nil
case sqltypes.Uint16:
return Uint16Type, nil
case sqltypes.Uint24:
return Uint24Type, nil
case sqltypes.Uint32:
return Uint32Type, nil
case sqltypes.Uint64:
return Uint64Type, nil
case sqltypes.Float32:
return Float32Type, nil
case sqltypes.Float64: