DDC-195: Ordering of associations #242

Closed
opened 2026-01-22 12:32:02 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 6, 2009).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user romanb:

It should be supported to set a default ordering for associations.

Example:

/****
 * @OneToMany(targetEntity="Thing", mappedBy="other")
 * @OrderBy("foo*bar ASC, other*bar DESC")
 */
private $things;

The value of the orderby mapping declaration should be a simple DQL snippet.

Main classes to adjust for this feature: SqlWalker, StandardEntityPersister and the metadata drivers, of course.

Originally created by @doctrinebot on GitHub (Dec 6, 2009). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user romanb: It should be supported to set a default ordering for associations. Example: ``` /**** * @OneToMany(targetEntity="Thing", mappedBy="other") * @OrderBy("foo*bar ASC, other*bar DESC") */ private $things; ``` The value of the orderby mapping declaration should be a simple **DQL snippet**. Main classes to adjust for this feature: SqlWalker, StandardEntityPersister and the metadata drivers, of course.
admin added the Improvement label 2026-01-22 12:32:02 +01:00
admin closed this issue 2026-01-22 12:32:02 +01:00
Author
Owner
@doctrinebot commented on GitHub (Dec 6, 2009): - depends on [DDC-335: Refactor DQL EBNF to use JOIN FETCH as syntax for fetch joins only](http://www.doctrine-project.org/jira/browse/DDC-335) - is duplicated by [DDC-181: Order of many-to-many relationship](http://www.doctrine-project.org/jira/browse/DDC-181) - relates to [DDC-293: Patch for "orderBy" attribute for @ManyToMany](http://www.doctrine-project.org/jira/browse/DDC-293)
Author
Owner

@doctrinebot commented on GitHub (Jan 31, 2010):

Comment created by @beberlei:

is @OrderBy("string") supported by our parser? I know its the JPA 2.0 equivalent, but imho:

@OneToMany(..., orderBy="snippet")

My patch in DDC-293 uses fields instead of columns though.

Also does the SqlWalker need a change? Is it possible to reliably add the order by clauses when there is already an ORDER BY statement in the query?

@doctrinebot commented on GitHub (Jan 31, 2010): Comment created by @beberlei: is @OrderBy("string") supported by our parser? I know its the JPA 2.0 equivalent, but imho: ``` @OneToMany(..., orderBy="snippet") ``` My patch in [DDC-293](http://www.doctrine-project.org/jira/browse/DDC-293) uses fields instead of columns though. Also does the SqlWalker need a change? Is it possible to reliably add the order by clauses when there is already an ORDER BY statement in the query?
Author
Owner

@doctrinebot commented on GitHub (Feb 14, 2010):

Comment created by @beberlei:

The issue for @OrderBy(sql) is dependent on the DQL EBNF refactoring, its not possible to easily implement this without.

@doctrinebot commented on GitHub (Feb 14, 2010): Comment created by @beberlei: The issue for @OrderBy(sql) is dependent on the DQL EBNF refactoring, its not possible to easily implement this without.
Author
Owner

@doctrinebot commented on GitHub (Feb 20, 2010):

Comment created by @beberlei:

The mapping syntax will be changed in a future commit. Otherwise this is all implemented now.

@doctrinebot commented on GitHub (Feb 20, 2010): Comment created by @beberlei: The mapping syntax will be changed in a future commit. Otherwise this is all implemented now.
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Comment created by @beberlei:

This is now completely implemented and the API is finalized.

@doctrinebot commented on GitHub (Feb 26, 2010): Comment created by @beberlei: This is now completely implemented and the API is finalized.
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 26, 2010): 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#242