Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

Awkan
Copy link
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
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

@@ -9,7 +9,7 @@
<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
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

@@ -68,7 +68,7 @@
<cascade-persist/>
</cascade>
<order-by>
<order-by-field name="number" direction="ASC" />
Copy link
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

@@ -49,7 +49,7 @@
<cascade-merge/>
</cascade>
<order-by>
<order-by-field name="number" direction="ASC" />
Copy link
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
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
Contributor Author

Awkan commented Mar 22, 2018

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

@Ocramius
Copy link
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