You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "jameshartig (via GitHub)" <gi...@apache.org> on 2025/01/03 21:23:55 UTC
Re: [I] CASSGO-36 Could MapScan() get nil instead of zero value for null value? [cassandra-gocql-driver]
jameshartig commented on issue #1699:
URL: https://github.com/apache/cassandra-gocql-driver/issues/1699#issuecomment-2569836357
Rather than changing the `TypeInfo` interface and gocql you can do this yourself if you really need it. That's what my employer does.
Your loop would instead look something like:
```go
for {
rowData, err := iter.RowData()
if err != nil {
return nil, err
}
m := make(map[string]interface{}, len(columns))
values := make([]interface{}, len(columns))
for i, v := range rowData.Values {
m[rowData.Columns[i]] = v
values[i] = reflect.ValueOf(v).Addr().Interface()
}
if !iter.Scan(values...) {
break
}
// Handle NaN values
for key, value := range m {
if f, ok := value.(*float64); ok && f != nil && math.IsNaN(*f) {
m[key] = "NaN"
}
}
results = append(results, m)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org