From 721ae797169b2f5bd98174a6443fe7cc73b7f24b Mon Sep 17 00:00:00 2001 From: Sasha <64744993+r1tsuu@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:45:11 +0200 Subject: [PATCH] fix: `populate` with find operation (#9087) ### What? Because of my error, we didn't pass `populate` to `findOperation` from the Local API. ### Why? `populate` must work for every operation that has `depth`. ### How? Passes `populate` in `operations/local/find.ts`, ensures it works with the test, checked that other operations pass it. --- .../src/collections/operations/local/find.ts | 3 ++- test/select/int.spec.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/payload/src/collections/operations/local/find.ts b/packages/payload/src/collections/operations/local/find.ts index 923e9b5141..c0e676bdd9 100644 --- a/packages/payload/src/collections/operations/local/find.ts +++ b/packages/payload/src/collections/operations/local/find.ts @@ -67,8 +67,8 @@ export async function findLocal< overrideAccess = true, page, pagination = true, + populate, select, - // select, showHiddenFields, sort, where, @@ -94,6 +94,7 @@ export async function findLocal< overrideAccess, page, pagination, + populate, req: await createLocalReq(options, payload), select, showHiddenFields, diff --git a/test/select/int.spec.ts b/test/select/int.spec.ts index 1ef65779a2..07217d51f6 100644 --- a/test/select/int.spec.ts +++ b/test/select/int.spec.ts @@ -1817,6 +1817,25 @@ describe('Select', () => { id: aboutPage.id, }) + const { + docs: [resultFind], + } = await payload.find({ + collection: 'pages', + depth: 1, + populate: { + pages: { + additional: true, + }, + }, + where: { + id: { + equals: aboutPage.id, + }, + }, + }) + + expect(resultFind).toStrictEqual(result) + const { content: [ {