From 8d68e54a0b3d04fda823a011894f52703da55e4b Mon Sep 17 00:00:00 2001 From: Ryan Stonebraker Date: Wed, 9 Oct 2024 20:25:19 -0700 Subject: [PATCH] Fixes bug when upserting widget with blanked out id --- api/ws/handlers/screen-configuration.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/api/ws/handlers/screen-configuration.go b/api/ws/handlers/screen-configuration.go index 892523cd..610287a0 100644 --- a/api/ws/handlers/screen-configuration.go +++ b/api/ws/handlers/screen-configuration.go @@ -175,11 +175,9 @@ func writeScreenConfiguration(screenConfig *protos.ScreenConfiguration, hctx wsH widget.Id = formWidgetId(widget, screenConfig.Id, i) if widget.Data != nil { // We have widget data, but no ID, so write it to the database with a new ID - _, err := hctx.Svcs.MongoDB.Collection(dbCollections.WidgetDataName).UpdateOne(sessCtx, bson.M{ - "_id": widget.Id, - }, bson.M{ - "$set": widget.Data, - }, options.Update().SetUpsert(true)) + widget.Data.Id = widget.Id + _, err := hctx.Svcs.MongoDB.Collection(dbCollections.WidgetDataName).InsertOne(sessCtx, widget.Data) + if err != nil { return nil, err }