-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Context
I have a oneToMany relation between 2 entities. For example an Article which has many tags.
class Article
{
private $id;
private $name;
private $tags;
public function __construct()
{
$this->tags = new ArrayCollection();
}
}
class Tag
{
private $id;
private $name;
}My mapping is declared as XML.
Then, I want to get my tags ordered by name. For that, I have the following mapping in my Article:
<entity name="Article">
<!-- ... -->
<one-to-many field="tags" target-entity="Tag">
<order-by>
<order-by-field name="name"/>
</order-by>
</one-to-many>
</entity>Problem
By default, this should sort my name field ASC (as mentionned in XSD file). However I have the exception Invalid order by orientation specified for Tag#name
Way of solution
For the moment, adding explicitly my direction attribute works fine but the default value isn't very default
<entity name="Article">
<!-- ... -->
<one-to-many field="tags" target-entity="Tag">
<order-by>
<order-by-field name="name" direction="ASC"/>
</order-by>
</one-to-many>
</entity>I've investigate about it and it's appear that during the mapping reading (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L375), the default direction isn't set. Should be set it by default to this line ?
Reactions are currently unavailable