fix(db-postgres): deleteOne fails when the where query does not resolve to any document (#11632)

Previously, if you called `payload.db.deleteOne` with a `where` query
that does not resolve to anything, an error would be occurred.
This commit is contained in:
Sasha
2025-04-04 00:46:31 +03:00
committed by GitHub
parent fae113b799
commit 4ebd3ce668
2 changed files with 14 additions and 0 deletions

View File

@@ -2134,6 +2134,16 @@ describe('database', () => {
expect(query3.totalDocs).toEqual(1)
})
it('db.deleteOne should not fail if query does not resolve to any document', async () => {
await expect(
payload.db.deleteOne({
collection: 'posts',
returning: false,
where: { title: { equals: 'some random title' } },
}),
).resolves.toBeNull()
})
it('mongodb additional keys stripping', async () => {
// eslint-disable-next-line jest/no-conditional-in-test
if (payload.db.name !== 'mongoose') {