From fb6a6b52fa36128d9a03f09ec168744ded881308 Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Thu, 18 Dec 2025 15:21:32 +0100 Subject: [PATCH] =?UTF-8?q?fix(order):=20Prevent=20fetching=20all=20db=20a?= =?UTF-8?q?djustments=20when=20no=20items=20are=20pre=E2=80=A6=20(#14351)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(order): Prevent fetching all db adjustments when no items are present * Create funny-suns-think.md --- .changeset/funny-suns-think.md | 5 +++++ packages/modules/order/src/utils/base-repository-find.ts | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .changeset/funny-suns-think.md diff --git a/.changeset/funny-suns-think.md b/.changeset/funny-suns-think.md new file mode 100644 index 0000000000..557bfb2b64 --- /dev/null +++ b/.changeset/funny-suns-think.md @@ -0,0 +1,5 @@ +--- +"@medusajs/order": patch +--- + +fix(order): Prevent fetching all db adjustments when no items are pre… diff --git a/packages/modules/order/src/utils/base-repository-find.ts b/packages/modules/order/src/utils/base-repository-find.ts index 04fac94ab3..d7e12f68ac 100644 --- a/packages/modules/order/src/utils/base-repository-find.ts +++ b/packages/modules/order/src/utils/base-repository-find.ts @@ -225,6 +225,10 @@ async function loadItemAdjustments(manager, orders) { const items = orders.flatMap((r) => [...(r.items ?? [])]) const itemsIdMap = new Map(items.map((i) => [i.item.id, i.item])) + if (!items.length) { + return + } + const params = items.map((i) => { // preinitialise all items so an empty array is returned for ones without adjustments if (!i.item.adjustments.isInitialized()) {