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

Closed
opened 2026-01-22 14:35:20 +01:00 by admin · 3 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:20 +01:00
admin closed this issue 2026-01-22 14:35:20 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 22, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1146] was assigned:
https://github.com/doctrine/doctrine2/pull/1146

@doctrinebot commented on GitHub (Oct 22, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1146] was assigned: https://github.com/doctrine/doctrine2/pull/1146
Author
Owner

@doctrinebot commented on GitHub (Oct 22, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1146] was closed:
https://github.com/doctrine/doctrine2/pull/1146

@doctrinebot commented on GitHub (Oct 22, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1146] was closed: https://github.com/doctrine/doctrine2/pull/1146
Author
Owner

@doctrinebot commented on GitHub (Oct 22, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 22, 2014): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4108