SQL Expressions: Replace NaN/Inf values with Null (#112641)
This is because MySQL doesn't support storing of NaN valuels, and therefore go-mysql-server isn't going to either. Float fields/columns are always mapped to be nullable now, otherwise we would have to replace NaN/Inf with 0.
This commit is contained in:
@@ -130,7 +130,8 @@ func MySQLColToFieldType(col *mysql.Column) (data.FieldType, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if col.Nullable {
|
||||
// Floats are always nullable so we can map NaN/Inf values to null
|
||||
if col.Nullable || fT == data.FieldTypeFloat32 || fT == data.FieldTypeFloat64 {
|
||||
fT = fT.NullableType()
|
||||
}
|
||||
|
||||
@@ -172,10 +173,10 @@ func fieldValFromRowVal(fieldType data.FieldType, val interface{}) (interface{},
|
||||
return parseVal[uint64](val, "uint64", nullable)
|
||||
|
||||
case data.FieldTypeFloat32, data.FieldTypeNullableFloat32:
|
||||
return parseVal[float32](val, "float32", nullable)
|
||||
return parseVal[float32](val, "float32", true)
|
||||
|
||||
case data.FieldTypeFloat64, data.FieldTypeNullableFloat64:
|
||||
return parseFloat64OrDecimal(val, nullable)
|
||||
return parseFloat64OrDecimal(val, true)
|
||||
|
||||
case data.FieldTypeTime, data.FieldTypeNullableTime:
|
||||
return parseVal[time.Time](val, "time.Time", nullable)
|
||||
|
||||
Reference in New Issue
Block a user