Skip to content

Commit eb8d2d3

Browse files
authored
Fix dse_version when it's null (#95)
1 parent 4af7baa commit eb8d2d3

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

proxycore/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ func (c *Cluster) queryHosts(ctx context.Context, conn *ClientConn, version prim
316316
return nil, ClusterInfo{}, err
317317
}
318318

319-
dseVersion, err := row.StringByName("dse_version") // It's okay if this doesn't exist
320-
if err != nil && err != ColumnNameNotFound {
319+
dseVersion, err := row.StringByName("dse_version") // It's okay if this doesn't exist (or is null)
320+
if err != nil && err != ColumnNameNotFound && err != ColumnIsNull {
321321
return nil, ClusterInfo{}, err
322322
}
323323

proxycore/resultset.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
var (
2727
ColumnNameNotFound = errors.New("column name not found")
28+
ColumnIsNull = errors.New("column is null")
2829
)
2930

3031
type ResultSet struct {
@@ -81,7 +82,9 @@ func (r Row) StringByName(n string) (string, error) {
8182
if err != nil {
8283
return "", err
8384
}
84-
if s, ok := val.(string); !ok {
85+
if val == nil {
86+
return "", ColumnIsNull
87+
} else if s, ok := val.(string); !ok {
8588
return "", fmt.Errorf("'%s' is not a string", n)
8689
} else {
8790
return s, nil
@@ -93,8 +96,10 @@ func (r Row) InetByName(n string) (net.IP, error) {
9396
if err != nil {
9497
return nil, err
9598
}
96-
if ip, ok := val.(net.IP); !ok {
97-
return nil, fmt.Errorf("'%s' is not an inet", n)
99+
if val == nil {
100+
return nil, ColumnIsNull
101+
} else if ip, ok := val.(net.IP); !ok {
102+
return nil, fmt.Errorf("'%s' is not an inet (or is null)", n)
98103
} else {
99104
return ip, nil
100105
}
@@ -105,8 +110,10 @@ func (r Row) UUIDByName(n string) (primitive.UUID, error) {
105110
if err != nil {
106111
return [16]byte{}, err
107112
}
108-
if u, ok := val.(primitive.UUID); !ok {
109-
return [16]byte{}, fmt.Errorf("'%s' is not a uuid", n)
113+
if val == nil {
114+
return [16]byte{}, ColumnIsNull
115+
} else if u, ok := val.(primitive.UUID); !ok {
116+
return [16]byte{}, fmt.Errorf("'%s' is not a uuid (or is null)", n)
110117
} else {
111118
return u, nil
112119
}

0 commit comments

Comments
 (0)