Skip to content

Commit

Permalink
feat: Allow store reading as null value
Browse files Browse the repository at this point in the history
Allow store reading as null value

Signed-off-by: bruce <weichou1229@gmail.com>
  • Loading branch information
weichou1229 committed Oct 7, 2024
1 parent eff0073 commit faff7e1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/eclipse/paho.mqtt.golang v1.5.0
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.2.0-dev.58
github.com/edgexfoundry/go-mod-configuration/v3 v3.2.0-dev.17
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.48
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.49
github.com/edgexfoundry/go-mod-messaging/v3 v3.2.0-dev.35
github.com/edgexfoundry/go-mod-secrets/v3 v3.2.0-dev.12
github.com/fxamacker/cbor/v2 v2.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ github.com/edgexfoundry/go-mod-bootstrap/v3 v3.2.0-dev.58 h1:AHp6ChEe44PhQX72Ord
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.2.0-dev.58/go.mod h1:MoAhP94mD4GI1ReeHQz0M7R4vD8MlA3/paP3u6QrEM4=
github.com/edgexfoundry/go-mod-configuration/v3 v3.2.0-dev.17 h1:eNLGThT5fYtFLSrr6vtvHV92cm5IohJzwSRYcd5pvtg=
github.com/edgexfoundry/go-mod-configuration/v3 v3.2.0-dev.17/go.mod h1:va3l+Nri1KijDM5KItsaYrwUSG3Nhj/4EDvR4uB+Jds=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.48 h1:wL2f6AFsByGGXfmez7LdEKsK4oMnGprJqK6PA/RpS/g=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.48/go.mod h1:MLk37/79M26+bZr3IptNZuYmQBEVbXwzDp1VHQkFhIk=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.49 h1:uBI0nA3oO9P2MWBR1Tcn/543u4GFfWXd4J9Gii6CB1k=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.2.0-dev.49/go.mod h1:MLk37/79M26+bZr3IptNZuYmQBEVbXwzDp1VHQkFhIk=
github.com/edgexfoundry/go-mod-messaging/v3 v3.2.0-dev.35 h1:ZKmq5Vd1QN86OLTbD8A2JIKTxR8k21gtqmEUS3hApBY=
github.com/edgexfoundry/go-mod-messaging/v3 v3.2.0-dev.35/go.mod h1:SUTdo8v9V+XacowkZP5puBXnBcVP2NDSk5PBzOdsLEk=
github.com/edgexfoundry/go-mod-registry/v3 v3.2.0-dev.16 h1:vG6cI1LU8QLpzUXYleYuVyqbpeYghLF3Jj6afcaUCHA=
Expand Down
10 changes: 5 additions & 5 deletions internal/core/data/application/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var persistedEvent = models.Event{

func buildReadings() []models.Reading {
ticks := pkgCommon.MakeTimestamp()

testValue := "45"
r1 := models.SimpleReading{
BaseReading: models.BaseReading{
Id: uuid.New().String(),
Expand All @@ -57,7 +57,7 @@ func buildReadings() []models.Reading {
ProfileName: "TempProfile",
ValueType: common.ValueTypeUint16,
},
Value: "45",
Value: &testValue,
}

r2 := models.BinaryReading{
Expand All @@ -81,7 +81,7 @@ func buildReadings() []models.Reading {
ProfileName: "TempProfile",
ValueType: common.ValueTypeUint16,
},
Value: "33",
Value: &testValue,
}

r4 := models.SimpleReading{
Expand All @@ -93,7 +93,7 @@ func buildReadings() []models.Reading {
ProfileName: "TempProfile",
ValueType: common.ValueTypeUint16,
},
Value: "44",
Value: &testValue,
}

r5 := models.SimpleReading{
Expand All @@ -105,7 +105,7 @@ func buildReadings() []models.Reading {
ProfileName: "TempProfile",
ValueType: common.ValueTypeUint16,
},
Value: "55",
Value: &testValue,
}

var readings []models.Reading
Expand Down
2 changes: 1 addition & 1 deletion internal/core/data/controller/http/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var persistedReading = models.SimpleReading{
ProfileName: TestDeviceProfileName,
ValueType: common.ValueTypeUint8,
},
Value: TestReadingValue,
Value: &testReadingValue,
}

var persistedEvent = models.Event{
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/infrastructure/postgres/reading.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func queryReadings(ctx context.Context, connPool *pgxpool.Pool, sql string, args
// reading type is SimpleReading
simpleReading := model.SimpleReading{
BaseReading: baseReading,
Value: *readingDBModel.Value,
Value: readingDBModel.Value,
}
reading = simpleReading
} else {
Expand Down Expand Up @@ -342,7 +342,7 @@ func addReadingsInTx(tx pgx.Tx, readings []model.Reading, eventId string) error
// convert SimpleReading struct to Reading DB model
readingDBModel = dbModels.Reading{
BaseReading: baseReading,
SimpleReading: dbModels.SimpleReading{Value: &contractReadingModel.Value},
SimpleReading: dbModels.SimpleReading{Value: contractReadingModel.Value},
}
default:
return errors.NewCommonEdgeX(errors.KindContractInvalid, "failed to convert reading to none of BinaryReading/ObjectReading/SimpleReading structs", nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/infrastructure/redis/reading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
)

func simpleReadingData() models.SimpleReading {
testValue := "123"
return models.SimpleReading{
BaseReading: models.BaseReading{
Id: exampleUUID,
Expand All @@ -32,7 +33,7 @@ func simpleReadingData() models.SimpleReading {
ResourceName: testResourceName,
ValueType: common.ValueTypeString,
},
Value: "123",
Value: &testValue,
}
}

Expand Down

0 comments on commit faff7e1

Please sign in to comment.