fix(medusa): Deleted discount missing on order (#6837)

* Fix deleted discount missing on order

* Added integration test

* Added changeset
This commit is contained in:
pepijn-vanvlaanderen
2024-03-29 11:51:27 +01:00
committed by GitHub
parent 86f499de2f
commit 6113af0a66
3 changed files with 39 additions and 2 deletions
+6 -2
View File
@@ -10,6 +10,7 @@ import {
const ITEMS_REL_NAME = "items"
const REGION_REL_NAME = "region"
const DISCOUNTS_REL_NAME = "discounts"
export const OrderRepository = dataSource.getRepository(Order).extend({
async findWithRelations(
@@ -28,8 +29,11 @@ export const OrderRepository = dataSource.getRepository(Order).extend({
where: { id: In(entitiesIds) },
select: ["id"],
relations: rels,
withDeleted:
topLevel === ITEMS_REL_NAME || topLevel === REGION_REL_NAME,
withDeleted: [
ITEMS_REL_NAME,
REGION_REL_NAME,
DISCOUNTS_REL_NAME,
].includes(topLevel),
relationLoadStrategy: "join",
})
})