Skip to content

Commit

Permalink
revert: "feat: Allow store reading as null value"
Browse files Browse the repository at this point in the history
This reverts commit faff7e1

Signed-off-by: bruce <[email protected]>
  • Loading branch information
weichou1229 committed Oct 17, 2024
1 parent 0f2c1aa commit 636acee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
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: &testValue,
Value: "45",
}

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

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

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

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 @@ -258,7 +258,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 @@ -351,7 +351,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: 1 addition & 2 deletions internal/pkg/infrastructure/redis/reading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const (
)

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

Expand Down

0 comments on commit 636acee

Please sign in to comment.