#18355·payload

db-mongodb: `where` conditions silently dropped when querying through a relationship with access control

Author: avee87Created Sep 28, 2026Updated Sep 29, 2026
Labelsstatus: needs-triagedb: mongodbarea: coreBugv3

Describe the Bug

With overrideAccess: false, querying through a relationship silently drops other conditions in the same where object. The query returns documents that don't match the filter.

typescript
await payload.find({
  collection: 'posts',
  overrideAccess: false,
  where: {
    'category.slug': { equals: 'a' },
    'category.state': { equals: 'active' },
  },
})

This returns posts from every category the user can read, not just a. categories has a read access function that returns a Where (e.g. { state: { not_equals: 'hidden' } }).

Other conditions in the same where object are dropped the same way:

  • two conditions on the same relationship (category.slug + category.state)
  • several operators on one field (date: { greater_than_equal, less_than_equal })
  • exists / like / not_like on any field

The same conditions wrapped in and: [...] work correctly.

Link to the code that reproduces this issue

https://github.com/avee87/payload-relationship-where-and-issue

Reproduction Steps

In reproduction repo:

  1. pnpm install
  2. pnpm test:int (runs against mongodb-memory-server, no DB needed)
  3. 3 tests in tests/int/relationshipWhere.int.spec.ts fail:
    • two conditions on the same relationship: also returns the post from category b
    • relationship condition next to exists: the exists condition is ignored
    • two conditions on the same relationship next to an explicit and (overrideAccess: true): category.* conditions are ignored
  4. The control test, with the same conditions wrapped in and: [...], passes

Which area(s) are affected?

area: core, db: mongodb

Environment Info

Binaries:
  Node: 26.9.0
  npm: 11.19.1
  Yarn: N/A
  pnpm: 12.4.2
Relevant Packages:
  payload: 3.90.2
  next: 16.3.3
  @payloadcms/db-mongodb: 3.90.2
  @payloadcms/graphql: 3.90.2
  @payloadcms/next/utilities: 3.90.2
  @payloadcms/richtext-lexical: 3.90.2
  @payloadcms/translations: 3.90.2
  @payloadcms/ui/shared: 3.90.2
  react: 19.2.6
  react-dom: 19.2.6
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Tue Jul 21 20:49:22 PDT 2026; root:xnu-11417.140.69.711.44~1/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8