Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ensure that OrderFilter preserves the query string parameters order #1710

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

Merged
merged 1 commit into from
Feb 16, 2018

Conversation

antograssiot
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

When requesting the API with a url like /foo?order[baz]=asc&order[bar]=asc the order is not preserved anymore as it used to be since 1.0

The root cause is the Symfony Request::getQueryString() not preserving the order when re-generating the string.

For now I've ported the Symfony function and removed the sorting thing for now.

@antograssiot antograssiot force-pushed the maintain-order-in-filters branch from 8c3f4ae to fb7cc47 Compare February 16, 2018 13:13
@antograssiot
Copy link
Contributor Author

I'm definitely not a fan of the code duplication that it generates and I'm open to any other option.

@@ -300,6 +300,67 @@ Feature: Order filter on collections
}
"""

Scenario: Get collection ordered collection on several property keep the order
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dunglas Should I open a MR to add this test to 2.1 also ?

@soyuka
Copy link
Member

soyuka commented Feb 16, 2018

I'm definitely not a fan of the code duplication that it generates and I'm open to any other option.

Shouldn't that be fixed in symfony then? If not then 👍

@dunglas
Copy link
Member

dunglas commented Feb 16, 2018

It should be fixed in SF, but we need a workaround in the meantime.

@antograssiot
Copy link
Contributor Author

I'll open a PR to symfony also @soyuka and remove this when an upsteam patch will be availlable. I also don't know in which version of symfony it will end in (if it does get merged), and it might force to pin to a higher version than today which can also not be acceptable for this projet...

@dunglas dunglas merged commit 45c537f into api-platform:master Feb 16, 2018
@dunglas
Copy link
Member

dunglas commented Feb 16, 2018

Thanks @antograssiot

@antograssiot antograssiot deleted the maintain-order-in-filters branch February 16, 2018 15:18
@antograssiot
Copy link
Contributor Author

@soyuka @dunglas I gave a try to allow that in symfony directly as promised.
symfony/symfony#26202

hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
…-in-filters

Ensure that OrderFilter preserves the query string parameters order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants