remove delete components fix

This commit is contained in:
Marc-Roig 2022-08-11 14:52:35 +02:00
parent c56ddfb253
commit dad7237a44
2 changed files with 2 additions and 13 deletions

View File

@ -261,9 +261,8 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
return null;
}
// Delete entity components first, and then the entity
await deleteComponents(uid, entityToDelete);
await db.query(uid).delete({ where: { id: entityToDelete.id } });
await deleteComponents(uid, entityToDelete);
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
@ -283,9 +282,8 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
return null;
}
// Delete all the entities components first, and then the entities
await Promise.all(entitiesToDelete.map(entity => deleteComponents(uid, entity)));
const deletedEntities = await db.query(uid).deleteMany(query);
await Promise.all(entitiesToDelete.map(entity => deleteComponents(uid, entity)));
// Trigger webhooks. One for each entity
await Promise.all(entitiesToDelete.map(entity => this.emitEvent(uid, ENTRY_DELETE, entity)));

View File

@ -161,15 +161,6 @@ describe('Core API - Basic + compo + draftAndPublish', () => {
data.productsWithCompoAndDP.shift();
});
describe('database state', () => {
test('components have been removed from the database', async () => {
const dbComponents = await strapi.db
.query('default.compo')
.findMany({ name: 'compo name updated' });
expect(dbComponents).toHaveLength(0);
});
});
describe('validation', () => {
test('Cannot create product with compo - compo required', async () => {
const product = {