DDC-3322: [GH-1146] Allow orderBy to reference associations #4107

Open
opened 2026-01-22 14:35:18 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 23, 2014).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of c960657:

Url: https://github.com/doctrine/doctrine2/pull/1146

Message:

If I specify an order-by clause on a to-many association, e.g. @OrderBy({"foo" = "ASC"}), where foo is a to-one-association on the target entity, the collection is sorted by foo_id (this behaviour is implemented in BasicEntityPersister::getOrderBySQL()).

This works fine. However, Doctrine\ORM\Tools\SchemaValidator complains that foo is not a field.

This change makes the validator accept order-by clauses on associations where the target entity is the owning side, and the association is single-valued (AFAICT this is the same restrictions that BasicEntityPersister uses).

Originally created by @doctrinebot on GitHub (Sep 23, 2014). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of c960657: Url: https://github.com/doctrine/doctrine2/pull/1146 Message: If I specify an order-by clause on a to-many association, e.g. `@OrderBy({"foo" = "ASC"})`, where foo is a to-one-association on the target entity, the collection is sorted by foo_id (this behaviour is implemented in BasicEntityPersister::getOrderBySQL()). This works fine. However, Doctrine\ORM\Tools\SchemaValidator complains that foo is not a field. This change makes the validator accept order-by clauses on associations where the target entity is the owning side, and the association is single-valued (AFAICT this is the same restrictions that BasicEntityPersister uses).
admin added the Bug label 2026-01-22 14:35:18 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4107