From b61577da4774f6b5ce32c3959afb67861dc87abb Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Wed, 12 Jun 2024 19:20:30 +0530 Subject: [PATCH] chore: Remove `updateAndFind` (#34204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This method is only partially implemented (see the `updateExecuteAndFind`), is only used in one place, and isn't implemented at all in `pg` branch. Removing this method reduces the diff, and avoids more usages of this method that's missing on `pg`. **/test sanity** > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: b4d3023e8e8275a3ea7e5e7e3b91d91c116e6bb8 > Cypress dashboard url: Click here! ## Summary by CodeRabbit - **Refactor** - Improved the internal structure of the update method for better code organization and maintainability. --- .../ce/BaseAppsmithRepositoryCEImpl.java | 20 +++---------------- .../ce/params/QueryAllParams.java | 5 ----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java index 0811b0e6e6f4..ef44c1b977b4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java @@ -129,10 +129,9 @@ public Mono updateById(@NonNull String id, @NonNull T resource, AclPermission // Set policies to null in the update object resource.setPolicies(null); - return queryBuilder() - .byId(id) - .permission(permission) - .updateFirstAndFind(buildUpdateFromSparseResource(resource)); + final QueryAllParams q = queryBuilder().byId(id).permission(permission); + + return q.updateFirst(buildUpdateFromSparseResource(resource)).then(Mono.defer(q::one)); } public Mono updateByIdWithoutPermissionCheck(@NonNull String id, BridgeUpdate update) { @@ -356,19 +355,6 @@ public Mono updateExecute(@NonNull QueryAllParams params, @NonNull U })); } - public Mono updateExecuteAndFind(@NonNull QueryAllParams params, @NonNull UpdateDefinition update) { - if (QueryAllParams.Scope.ALL.equals(params.getScope())) { - // Not implemented yet, since not needed yet. - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "scope")); - - } else if (QueryAllParams.Scope.FIRST.equals(params.getScope())) { - return updateExecute(params, update).then(Mono.defer(() -> queryOneExecute(params))); - - } else { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "scope")); - } - } - public BridgeUpdate buildUpdateFromSparseResource(T resource) { // In case the update is not used to update the policies, then set the policies to null to ensure that the // existing policies are not overwritten. diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java index d033eee0ee9f..3a4583d2ed31 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/params/QueryAllParams.java @@ -87,11 +87,6 @@ public Mono updateFirst(@NonNull UpdateDefinition update) { return repo.updateExecute(this, update); } - public Mono updateFirstAndFind(@NonNull UpdateDefinition update) { - scope = Scope.FIRST; - return repo.updateExecuteAndFind(this, update); - } - public QueryAllParams criteria(Criteria c) { if (c == null) { return this;