Skip to content

[Pagination] Support Symfony UID cursor fields - #4111

Open
norkunas wants to merge 1 commit into
symfony:3.xfrom
norkunas:pagination-uid-cursor
Open

norkunas wants to merge 1 commit into
symfony:3.xfrom
norkunas:pagination-uid-cursor

Conversation

@norkunas

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? yes
Issues -
License MIT

Entities identified by a Symfony UID cannot be cursor-paginated with Doctrine ORM. The first page renders, but following the "next" link fails, because the identifier is always appended as the tie-breaker:

$paginator->cursor($queryBuilder)->orderBy(['createdAt'], 'DESC')->paginate();
// Doctrine type "uuid" of cursor field "id" is not supported.

Binding a UID as a query parameter fails too, before any page is rendered:

$queryBuilder->andWhere('o.owner = :owner')->setParameter('owner', $userId, UuidType::NAME);
// Cannot derive a stable cursor context from Doctrine parameter object "Symfony\Component\Uid\UuidV7".

With this PR:

  • Cursor values hold a UID's string form (RFC 4122 for UUIDs, base32 for ULIDs)
  • When a cursor is read, the value is converted back through the field's own Doctrine type (any AbstractUidType, so uuid, ulid and custom subclasses) and bound with that type. The database then compares UIDs in its storage format (binary on SQLite/MySQL, native uuid on PostgreSQL), which is also the order ORDER BY uses
  • UID query parameters are fingerprinted in the cursor context as their class and string form

symfony/doctrine-bridge and symfony/uid are only needed as dev dependencies: the adapter checks instanceof, so nothing changes for applications without them.

#4102 edits the same type allow-list and the same docs sentence for date columns, so whichever is merged second needs a small rebase.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@carsonbot carsonbot added Documentation Improvements or additions to documentation Feature New Feature Pagination Status: Needs Review Needs to be reviewed labels Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Feature New Feature Pagination Status: Needs Review Needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants