Make updates synchronous by default
@@ -397,6 +397,7 @@ func configureAPI(api *operations.WeaviateAPI) http.Handler {
return actions.NewWeaviateActionsPatchUnprocessableEntity().WithPayload(createErrorResponseObject(validatedErr.Error()))
}
+ if params.Async != nil && *params.Async == true {
// Move the current properties to the history
delayedLock.IncSteps()
go func() {
@@ -419,6 +420,21 @@ func configureAPI(api *operations.WeaviateAPI) http.Handler {
// Returns accepted so a Go routine can process in the background
return actions.NewWeaviateActionsPatchAccepted().WithPayload(&actionGetResponse)
+ } else {
+ // Move the current properties to the history
+ dbConnector.MoveToHistoryAction(ctx, &oldAction.Action, params.ActionID, false)
+
+ err := dbConnector.UpdateAction(ctx, action, UUID)
+ if err != nil {
+ return actions.NewWeaviateActionUpdateUnprocessableEntity().WithPayload(createErrorResponseObject(err.Error()))
+ }
+
+ // Create return Object
+ actionGetResponse.Action = *action
+
+ // Returns accepted so a Go routine can process in the background
+ return actions.NewWeaviateActionsPatchOK().WithPayload(&actionGetResponse)
+ }
})
api.ActionsWeaviateActionsPropertiesCreateHandler = actions.WeaviateActionsPropertiesCreateHandlerFunc(func(params actions.WeaviateActionsPropertiesCreateParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation actions.WeaviateActionsPropertiesCreate has not yet been implemented")
@@ -1147,6 +1163,8 @@ func configureAPI(api *operations.WeaviateAPI) http.Handler {
updatedJSON, applyErr := patchObject.Apply(thingUpdateJSON)
if applyErr != nil {
+ fmt.Printf("patch attempt on %#v failed. Patch: %#v", thingUpdateJSON, patchObject)
+ panic("NOPE")
return things.NewWeaviateThingsPatchUnprocessableEntity().WithPayload(createErrorResponseObject(applyErr.Error()))
}
@@ -1164,6 +1182,7 @@ func configureAPI(api *operations.WeaviateAPI) http.Handler {
return things.NewWeaviateThingsPatchUnprocessableEntity().WithPayload(createErrorResponseObject(validatedErr.Error()))
}
+ if params.Async != nil && *params.Async == true {
// Move the current properties to the history
delayedLock.IncSteps()
go func() {
@@ -1183,6 +1202,23 @@ func configureAPI(api *operations.WeaviateAPI) http.Handler {
// Returns accepted so a Go routine can process in the background
return things.NewWeaviateThingsPatchAccepted().WithPayload(&thingGetResponse)
+ } else {
+ // Move the current properties to the history
+ dbConnector.MoveToHistoryThing(ctx, &oldThing.Thing, UUID, false)
+
+ // Update the database
+ err := dbConnector.UpdateThing(ctx, thing, UUID)
+
+ if err != nil {
+ return things.NewWeaviateThingsPatchUnprocessableEntity().WithPayload(createErrorResponseObject(err.Error()))
+ }
+
+ // Create return Object
+ thingGetResponse.Thing = *thing
+
+ // Returns accepted so a Go routine can process in the background
+ return things.NewWeaviateThingsPatchOK().WithPayload(&thingGetResponse)
+ }
})
api.ThingsWeaviateThingsPropertiesCreateHandler = things.WeaviateThingsPropertiesCreateHandlerFunc(func(params things.WeaviateThingsPropertiesCreateParams, principal interface{}) middleware.Responder {
return middleware.NotImplemented("operation things.WeaviateThingsPropertiesCreate has not yet been implemented")
