Skip to content

blockType filters don't work with versions on postgres #16070

@jmbockhorst

Description

@jmbockhorst

Describe the Bug

When querying a collection with a blocks field using draft=true and a where filter on blocks.blockType, it returns no results even though the published query returns the expected document.

This appears to affect the postgres adapter because versioned block rows are stored with _path = 'version.blocks', but the draft query constrains _path = 'blocks'. Mongo does not appear to be affected.

Link to the code that reproduces this issue

https://github.com/jmbockhorst/payload/blob/122514000a72f0e120bb96c28bf0f714ac5c16db/test/versions/int.spec.ts#L1830-L1873

Reproduction Steps

  1. Create a Payload app with a collection that has drafts enabled and a blocks field.
  2. Add a block with slug block-name.
  3. Create a document containing that block.
  4. Run a local API query without drafts enabled:
const publishedResults = await payload.find({
  collection: 'pages',
  where: {
    'blocks.blockType': {
      contains: 'block-name',
    },
  },
})

Confirm the document is returned.

Run the same query with draft: true:

const draftResults = await payload.find({
  collection: 'pages',
  draft: true,
  where: {
    'blocks.blockType': {
      contains: 'block-name',
    },
  },
})

Observe that draftResults.docs is empty.

Note that the versioned block row is stored with _path = 'version.blocks', but the draft query still filters on _path = 'blocks'.

Which area(s) are affected?

db: postgres

Environment Info

Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: N/A
  pnpm: 10.27.0
Relevant Packages:
  payload: 3.79.1
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:55:08 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions