payloadcms / payloadcms/payload

"or" filters on localized relationship fields only return matches for a single locale

Open
#14,527 3 comments 0 reactions 1 assignee View on GitHub

@r1tsuu is already working on this.

Since Feb 9, 2026.

stale
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

I have a collection Documents with a 1-N relationship to Revisions.

The field revisions.name is localized with two locales (e.g., it and en).

  • Filtering documents that have revisions in locale A works ✅
  • Filtering documents that have revisions in locale B works ✅

But combining both conditions with or only returns documents that match one of the locales (seemingly the default) ❌

It looks like and/or filters don’t behave correctly when applied to localized subfields inside related documents.

Link to the code that reproduces this issue

https://dev.daygbk4qgwfks.amplifyapp.com/api/documents

Reproduction Steps

Example response (GET /documents)

{
  "docs": [
    {   // Document with only locale B revision
      "id": 1,
      "revisions": {
        "docs": [
          {
            "id": 11,
            "name": { "en": "Revision one" }
          }
        ]
      }
    },
    {   // Document with both locales
      "id": 2,
      "revisions": {
        "docs": [
          {
            "id": 12,
            "name": { "it": "Revisione due", "en": "Revision two" }
          }
        ]
      }
    },
    {   // Document with only locale A revision
      "id": 3,
      "revisions": {
        "docs": [
          {
            "id": 14,
            "name": { "it": "Revisione tre" }
          }
        ]
      }
    }
  ]
}

✅ Working queries

  • Only locale A (example it):
{
  "and": [
    { "status": { "equals": "distributed" } },
    { "revisions.name.it": { "exists": true } }
  ]
}

✅ Working queries

  • Only locale B (example en):
{
  "and": [
    { "status": { "equals": "distributed" } },
    { "revisions.name.en": { "exists": true } }
  ]
}

❌ Failing query (unexpected result)

{
  "and": [
    { "status": { "equals": "distributed" } },
    {
      "or": [
        { "revisions.name.it": { "exists": true } },
        { "revisions.name.en": { "exists": true } }
      ]
    }
  ]
}
Which area(s) are affected? (Select all that apply)

Not sure

Environment Info
Binaries:
  Node: 20.18.3
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.13.1
Relevant Packages:
  payload: 3.49.1
  next: 15.3.0
  @payloadcms/db-mongodb: 3.49.1
  @payloadcms/db-postgres: 3.49.1
  @payloadcms/email-nodemailer: 3.49.1
  @payloadcms/graphql: 3.49.1
  @payloadcms/live-preview: 3.49.1
  @payloadcms/live-preview-react: 3.49.1
  @payloadcms/next/utilities: 3.49.1
  @payloadcms/payload-cloud: 3.49.1
  @payloadcms/plugin-cloud-storage: 3.49.1
  @payloadcms/plugin-form-builder: 3.49.1
  @payloadcms/plugin-nested-docs: 3.49.1
  @payloadcms/plugin-redirects: 3.49.1
  @payloadcms/plugin-search: 3.49.1
  @payloadcms/plugin-seo: 3.49.1
  @payloadcms/richtext-lexical: 3.49.1
  @payloadcms/storage-s3: 3.49.1
  @payloadcms/translations: 3.49.1
  @payloadcms/ui/shared: 3.49.1
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.