Skip to content

Commit

Permalink
chore: Remove updateAndFind (#34204)
Browse files Browse the repository at this point in the history
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**

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9482954144>
> Commit: b4d3023
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9482954144&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Improved the internal structure of the update method for better code
organization and maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
sharat87 authored Jun 12, 2024
1 parent 981e720 commit b61577d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ public Mono<T> 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<T> q = queryBuilder().byId(id).permission(permission);

return q.updateFirst(buildUpdateFromSparseResource(resource)).then(Mono.defer(q::one));
}

public Mono<Integer> updateByIdWithoutPermissionCheck(@NonNull String id, BridgeUpdate update) {
Expand Down Expand Up @@ -356,19 +355,6 @@ public Mono<Integer> updateExecute(@NonNull QueryAllParams<T> params, @NonNull U
}));
}

public Mono<T> updateExecuteAndFind(@NonNull QueryAllParams<T> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public Mono<Integer> updateFirst(@NonNull UpdateDefinition update) {
return repo.updateExecute(this, update);
}

public Mono<T> updateFirstAndFind(@NonNull UpdateDefinition update) {
scope = Scope.FIRST;
return repo.updateExecuteAndFind(this, update);
}

public QueryAllParams<T> criteria(Criteria c) {
if (c == null) {
return this;
Expand Down

0 comments on commit b61577d

Please sign in to comment.