Skip to content

[XML] Fix default value of one-to-many order-by to ASC#7146

Merged
mikeSimonson merged 1 commit intodoctrine:2.6from
Awkan:fix/7141-xml-order-by-default-asc
Apr 12, 2018
Merged

[XML] Fix default value of one-to-many order-by to ASC#7146
mikeSimonson merged 1 commit intodoctrine:2.6from
Awkan:fix/7141-xml-order-by-default-asc

Conversation

@Awkan
Copy link
Copy Markdown
Contributor

@Awkan Awkan commented Mar 21, 2018

Problem

As mentioned in issue #7141 , when we use XML mapping for a <one-to-many> relation with an <order-by> node, the default value direction=ASC isn't set by default.

Solution

In this PR, I define the default direction to ASC if not set

@Awkan Awkan changed the base branch from master to 2.6 March 21, 2018 09:00
@Awkan Awkan changed the title Fix/7141 xml order by default asc [XML] Fix default value of one-to-many order-by to ASC Mar 21, 2018
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
$orderBy[(string) $orderByField['name']] = isset($orderByField['direction'])
? (string) $orderByField['direction']
: 'ASC'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criteria::ASC if possible

<one-to-many field="attractions" target-entity="Doctrine\Tests\Models\Cache\Attraction" mapped-by="city">
<cache usage="READ_ONLY" />
<order-by>
<order-by-field name="name" direction="ASC"/>
Copy link
Copy Markdown
Member

@Ocramius Ocramius Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do define new mapping files for tests, and leave the existing ones be

<cascade-persist/>
</cascade>
<order-by>
<order-by-field name="number" direction="ASC" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert: use your own mapping file/scenario here please

<cascade-merge/>
</cascade>
<order-by>
<order-by-field name="number" direction="ASC" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert: use your own mapping file/scenario here please

Copy link
Copy Markdown
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test additions are still needed here

@Awkan Awkan force-pushed the fix/7141-xml-order-by-default-asc branch from 45b8089 to 762a9ac Compare March 22, 2018 13:50
@Awkan Awkan force-pushed the fix/7141-xml-order-by-default-asc branch from 762a9ac to 2560d4f Compare March 22, 2018 13:51
@Awkan
Copy link
Copy Markdown
Contributor Author

Awkan commented Mar 22, 2018

@Ocramius I've added a test, this was what you expect ?

@Ocramius
Copy link
Copy Markdown
Member

@Awkan yep, this matches, thanks 👍

@Ocramius Ocramius added this to the 2.6.2 milestone Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants