Skip to content

Commit

Permalink
fix edge case: array(float64) nan input. and csv converted to empty, …
Browse files Browse the repository at this point in the history
…we treated them null
  • Loading branch information
yokofly committed Oct 24, 2024
1 parent 2294238 commit aa1abdb
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions core/dbio/database/database_proton.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,10 @@ func (conn *ProtonConn) convertToArrayString(value interface{}) ([]string, error
return nil, nil
}

if value == "" {
return []string{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -944,6 +948,10 @@ func (conn *ProtonConn) convertToArrayInt8(value interface{}) ([]int8, error) {
return nil, nil
}

if value == "" {
return []int8{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -963,6 +971,10 @@ func (conn *ProtonConn) convertToArrayInt16(value interface{}) ([]int16, error)
return nil, nil
}

if value == "" {
return []int16{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -981,6 +993,10 @@ func (conn *ProtonConn) convertToArrayInt32(value interface{}) ([]int32, error)
return nil, nil
}

if value == "" {
return []int32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -999,6 +1015,10 @@ func (conn *ProtonConn) convertToArrayInt64(value interface{}) ([]int64, error)
return nil, nil
}

if value == "" {
return []int64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1017,6 +1037,10 @@ func (conn *ProtonConn) convertToArrayUint8(value interface{}) ([]uint8, error)
return nil, nil
}

if value == "" {
return []uint8{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1035,6 +1059,10 @@ func (conn *ProtonConn) convertToArrayUint16(value interface{}) ([]uint16, error
return nil, nil
}

if value == "" {
return []uint16{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1053,6 +1081,10 @@ func (conn *ProtonConn) convertToArrayUint32(value interface{}) ([]uint32, error
return nil, nil
}

if value == "" {
return []uint32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1072,6 +1104,10 @@ func (conn *ProtonConn) convertToArrayUint64(value interface{}) ([]uint64, error
return nil, nil
}

if value == "" {
return []uint64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1091,6 +1127,10 @@ func (conn *ProtonConn) convertToArrayFloat32(value interface{}) ([]float32, err
return nil, nil
}

if value == "" {
return []float32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1109,6 +1149,10 @@ func (conn *ProtonConn) convertToArrayFloat64(value interface{}) ([]float64, err
return nil, nil
}

if value == "" {
return []float64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1128,6 +1172,10 @@ func (conn *ProtonConn) convertToArrayBool(value interface{}) ([]bool, error) {
return nil, nil
}

if value == "" {
return []bool{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1148,6 +1196,10 @@ func (conn *ProtonConn) convertToMapStringUint64(value interface{}) (map[string]
return nil, nil
}

if value == "" {
return map[string]uint64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1167,6 +1219,10 @@ func (conn *ProtonConn) convertToMapStringUint32(value interface{}) (map[string]
return nil, nil
}

if value == "" {
return map[string]uint32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1186,6 +1242,10 @@ func (conn *ProtonConn) convertToMapStringInt32(value interface{}) (map[string]i
return nil, nil
}

if value == "" {
return map[string]int32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1205,6 +1265,10 @@ func (conn *ProtonConn) convertToMapStringInt64(value interface{}) (map[string]i
return nil, nil
}

if value == "" {
return map[string]int64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1224,6 +1288,10 @@ func (conn *ProtonConn) convertToMapStringFloat64(value interface{}) (map[string
return nil, nil
}

if value == "" {
return map[string]float64{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1243,6 +1311,10 @@ func (conn *ProtonConn) convertToMapStringFloat32(value interface{}) (map[string
return nil, nil
}

if value == "" {
return map[string]float32{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1262,6 +1334,10 @@ func (conn *ProtonConn) convertToMapInt32String(value interface{}) (map[int32]st
return nil, nil
}

if value == "" {
return map[int32]string{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1281,6 +1357,10 @@ func (conn *ProtonConn) convertToMapInt64String(value interface{}) (map[int64]st
return nil, nil
}

if value == "" {
return map[int64]string{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1300,6 +1380,10 @@ func (conn *ProtonConn) convertToMapStringArrayString(value interface{}) (map[st
return nil, nil
}

if value == "" {
return map[string][]string{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand All @@ -1319,6 +1403,10 @@ func (conn *ProtonConn) convertToMapStringString(value interface{}) (map[string]
return nil, nil
}

if value == "" {
return map[string]string{}, nil
}

str, ok := value.(string)
if !ok {
return nil, fmt.Errorf("expected string, got %T", value)
Expand Down

0 comments on commit aa1abdb

Please sign in to comment.