fix: Corrected usage of old soft deleted filter in BaseAppsmithRepository (#18238)
This commit is contained in:
parent
487e556dda
commit
9c1f9e4af8
|
|
@ -95,9 +95,17 @@ public abstract class BaseAppsmithRepositoryCEImpl<T extends BaseDomain> {
|
|||
}
|
||||
|
||||
public static final Criteria notDeleted() {
|
||||
return new Criteria().orOperator(
|
||||
where(fieldName(QBaseDomain.baseDomain.deleted)).exists(false),
|
||||
where(fieldName(QBaseDomain.baseDomain.deleted)).is(false)
|
||||
return new Criteria().andOperator(
|
||||
//Older check for deleted
|
||||
new Criteria().orOperator(
|
||||
where(FieldName.DELETED).exists(false),
|
||||
where(FieldName.DELETED).is(false)
|
||||
),
|
||||
//New check for deleted
|
||||
new Criteria().orOperator(
|
||||
where(FieldName.DELETED_AT).exists(false),
|
||||
where(FieldName.DELETED_AT).is(null)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.appsmith.server.dtos.RefactorActionNameDTO;
|
|||
import com.appsmith.server.dtos.WorkspacePluginStatus;
|
||||
import com.appsmith.server.helpers.MockPluginExecutor;
|
||||
import com.appsmith.server.helpers.PluginExecutorHelper;
|
||||
import com.appsmith.server.repositories.ActionCollectionRepository;
|
||||
import com.appsmith.server.repositories.PermissionGroupRepository;
|
||||
import com.appsmith.server.repositories.PluginRepository;
|
||||
import com.appsmith.server.repositories.WorkspaceRepository;
|
||||
|
|
@ -45,6 +46,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -101,6 +103,9 @@ public class ActionCollectionServiceTest {
|
|||
@Autowired
|
||||
PluginRepository pluginRepository;
|
||||
|
||||
@Autowired
|
||||
ActionCollectionRepository actionCollectionRepository;
|
||||
|
||||
@Autowired
|
||||
UserWorkspaceService userWorkspaceService;
|
||||
|
||||
|
|
@ -217,6 +222,42 @@ public class ActionCollectionServiceTest {
|
|||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to verify soft-deleted actionCollections are not retrieved in repository find methods.
|
||||
* This issue was observed when deprecated soft-delete field "deleted" is set to "false" and current field "deletedAt"
|
||||
* contains a non-null value.
|
||||
* Here deletedAt field is manually set to a non-null value instead of deleting actionCollection since that would
|
||||
* update both fields.
|
||||
*/
|
||||
@Test
|
||||
@WithUserDetails(value = "api_user")
|
||||
public void testCreateActionCollection_verifySoftDeletedCollectionIsNotLoaded() {
|
||||
Application application = new Application();
|
||||
application.setName(UUID.randomUUID().toString());
|
||||
|
||||
Application createdApplication = applicationPageService.createApplication(application, workspaceId).block();
|
||||
|
||||
assert createdApplication != null;
|
||||
final String pageId = createdApplication.getPages().get(0).getId();
|
||||
|
||||
ActionCollectionDTO actionCollectionDTO = new ActionCollectionDTO();
|
||||
actionCollectionDTO.setName("testActionCollectionSoftDeleted");
|
||||
actionCollectionDTO.setApplicationId(createdApplication.getId());
|
||||
actionCollectionDTO.setWorkspaceId(createdApplication.getWorkspaceId());
|
||||
actionCollectionDTO.setPageId(pageId);
|
||||
actionCollectionDTO.setPluginId(datasource.getPluginId());
|
||||
actionCollectionDTO.setPluginType(PluginType.JS);
|
||||
actionCollectionDTO.setDeletedAt(Instant.now());
|
||||
layoutCollectionService.createCollection(actionCollectionDTO).block();
|
||||
ActionCollection createdActionCollection = actionCollectionRepository.findByApplicationId(createdApplication.getId(), READ_ACTIONS, null).blockFirst();
|
||||
createdActionCollection.setDeletedAt(Instant.now());
|
||||
actionCollectionRepository.save(createdActionCollection).block();
|
||||
|
||||
StepVerifier.create(actionCollectionRepository.findByApplicationId(createdApplication.getId(), READ_ACTIONS, null))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@WithUserDetails(value = "api_user")
|
||||
public void createValidActionCollectionAndCheckPermissions() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user