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:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
mysql "github.com/dolthub/go-mysql-server/sql"
|
||||
@@ -92,6 +93,16 @@ func (ri *rowIter) Next(ctx *mysql.Context) (mysql.Row, error) {
|
||||
continue
|
||||
}
|
||||
val, _ := field.ConcreteAt(ri.row)
|
||||
switch v := val.(type) {
|
||||
case float32:
|
||||
if math.IsNaN(float64(v)) || math.IsInf(float64(v), 0) {
|
||||
continue
|
||||
}
|
||||
case float64:
|
||||
if math.IsNaN(v) || math.IsInf(v, 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// If the field is JSON, convert json.RawMessage to types.JSONDocument
|
||||
if raw, ok := val.(json.RawMessage); ok {
|
||||
|
||||
Reference in New Issue
Block a user