Skip to content

Commit

Permalink
Handled NULL values robustly
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-asplin-met-no committed Feb 14, 2024
1 parent a9886d3 commit 758afd8
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ func getTSMdata(colVals map[string]interface{}) (*datastore.TSMetadata, error) {
switch field.Kind() {
case reflect.String:
val0, ok := val.(string)
if !ok {
return nil, fmt.Errorf(
"value not string: %v (type: %T; goName: %s, pbName: %s",
val, val, goName, pbName)
if ok { // NOTE: !ok in this case would typically mean a nil value resulting from a
// NULL in the corresponding database column
field.SetString(val0)
}
field.SetString(val0)

default:
return nil, fmt.Errorf(
"unsupported type: %v (val: %v; type: %T; goName: %s; pbName: %s)",
Expand Down

1 comment on commit 758afd8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Unit Test Coverage Report
FileStmtsMissCoverMissing
\_\_init\_\_.py00100% 
datastore_pb2.py584621%24–69
datastore_pb2_grpc.py432347%37–52, 85–87, 92–94, 99–101, 106–108, 112–136, 174, 191, 208, 225
dependencies.py31487%23–24, 31, 38
grpc_getter.py8450%12–16
locustfile.py15150%1–31
main.py22386%27, 37, 47
metadata_endpoints.py19479%16, 33–66, 70
formatters
   \_\_init\_\_.py70100% 
   covjson.py46198%58
routers
   \_\_init\_\_.py00100% 
   edr.py711185%36–59, 109–110, 137–138
   records.py00100% 
TOTAL32011165% 

API Unit Test Coverage Summary

Tests Skipped Failures Errors Time
16 0 💤 0 ❌ 0 🔥 1.979s ⏱️

Please sign in to comment.