From dad7237a44c351daa1aec7032fbc59152b831299 Mon Sep 17 00:00:00 2001 From: Marc-Roig Date: Thu, 11 Aug 2022 14:52:35 +0200 Subject: [PATCH] remove delete components fix --- .../core/strapi/lib/services/entity-service/index.js | 6 ++---- .../core/strapi/tests/api/basic-dp-compo.test.e2e.js | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/core/strapi/lib/services/entity-service/index.js b/packages/core/strapi/lib/services/entity-service/index.js index 7342407c9c..6f543fb7d4 100644 --- a/packages/core/strapi/lib/services/entity-service/index.js +++ b/packages/core/strapi/lib/services/entity-service/index.js @@ -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))); diff --git a/packages/core/strapi/tests/api/basic-dp-compo.test.e2e.js b/packages/core/strapi/tests/api/basic-dp-compo.test.e2e.js index 95d8a60473..613d6cbaae 100644 --- a/packages/core/strapi/tests/api/basic-dp-compo.test.e2e.js +++ b/packages/core/strapi/tests/api/basic-dp-compo.test.e2e.js @@ -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 = {