diff --git a/internal/pkg/infrastructure/postgres/reading.go b/internal/pkg/infrastructure/postgres/reading.go index 33d4e4771a..20a0f28556 100644 --- a/internal/pkg/infrastructure/postgres/reading.go +++ b/internal/pkg/infrastructure/postgres/reading.go @@ -257,7 +257,12 @@ func queryReadings(ctx context.Context, connPool *pgxpool.Pool, sql string, args } reading = simpleReading } else { - return reading, errors.NewCommonEdgeX(errors.KindServerError, "failed to convert reading to none of BinaryReading/ObjectReading/SimpleReading structs", nil) + // reading type is NullReading + nullReading := model.NullReading{ + BaseReading: baseReading, + Value: nil, + } + reading = nullReading } return reading, nil @@ -348,6 +353,10 @@ func addReadingsInTx(tx pgx.Tx, readings []model.Reading, eventId string) error BaseReading: baseReading, SimpleReading: dbModels.SimpleReading{Value: &contractReadingModel.Value}, } + case model.NullReading: + readingDBModel = dbModels.Reading{ + BaseReading: baseReading, + } default: return errors.NewCommonEdgeX(errors.KindContractInvalid, "failed to convert reading to none of BinaryReading/ObjectReading/SimpleReading structs", nil) }