Fix/cascading product variant deletion (#570)

* testing for deletes of variants when a product is deleted

* remove variants with products

* test using direct db query

* formatting

* removed unused imports
This commit is contained in:
Philip Korsholm authored and GitHub committed 2021-10-22 09:20:59 +02:00
1 parent b0226b1975
commit 6b83653bf6
2 files changed
+45 -6

No files matched your search

+4 -1
View File
@@ -468,7 +468,10 @@ class ProductService extends BaseService {
const productRepo = manager.getCustomRepository(this.productRepository_)
// Should not fail, if product does not exist, since delete is idempotent
const product = await productRepo.findOne({ where: { id: productId } })
const product = await productRepo.findOne(
{ id: productId },
{ relations: ["variants"] }
)
if (!product) return Promise.resolve()