fix(db-mongodb): sort by fields in relationships with draft: true (#12387)

Fixes sorting by fields in relationships, e.g `sort: "author.name"` when
using `draft: true`. The existing test that includes check with `draft:
true` was accidentally passing because it used to sort by the
relationship field itself.
This commit is contained in:
Sasha
2025-05-12 22:35:16 +03:00
committed by GitHub
parent 8219c046de
commit fd67d461ac
3 changed files with 20 additions and 19 deletions

View File

@@ -670,18 +670,6 @@ describe('Relationships', () => {
await payload.delete({ collection: 'directors', where: {} })
await payload.delete({ collection: 'movies', where: {} })
const director_1 = await payload.create({
collection: 'directors',
data: { name: 'Dan', localized: 'Dan' },
})
await payload.update({
collection: 'directors',
id: director_1.id,
locale: 'de',
data: { localized: 'Mr. Dan' },
})
const director_2 = await payload.create({
collection: 'directors',
data: { name: 'Mr. Dan', localized: 'Mr. Dan' },
@@ -694,6 +682,18 @@ describe('Relationships', () => {
data: { localized: 'Dan' },
})
const director_1 = await payload.create({
collection: 'directors',
data: { name: 'Dan', localized: 'Dan' },
})
await payload.update({
collection: 'directors',
id: director_1.id,
locale: 'de',
data: { localized: 'Mr. Dan' },
})
const movie_1 = await payload.create({
collection: 'movies',
depth: 0,