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
e4e1b62 broke to_param
handling:
#33341
Conversation
r? @kaspth (@rails-bot has picked a reviewer for you, use r? to override) |
cc/ @rafaelfranca |
20ec47b
to
aae74f0
Compare
I think the best solution is to change |
8fb164a
to
2c165f5
Compare
2c165f5
to
b847cd6
Compare
…ture: - As discussed in rails#33341 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I think this skips some sorting that would still be permissible (and that a deeper fix could incidentally fix round-tripping on e.g. [{a:1,c:3},{b:2,c:4}]
), but I like the brevity of this change, and it's a good balance of keeping useful sorting without allowing it to break things. 👍
end.compact.sort! * "&" | ||
end.compact | ||
|
||
query.sort! unless namespace =~ /\[\w+\]\[\]/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is namespace.include?("[]")
sufficient here?
b847cd6
to
b177982
Compare
Thanks for the quick review friends 🤗 . Addressed your comment Matthew and squashed commits |
- There was an issue inside controller tests where order params were not respected, the reason was because we were calling `Hash#to_query` which sorts the results lexicographically. 1e4e1b62 fixed that issue by not using `to_query` but instead a utility function provided by rack. - However with the fix came another issue where it's now no longer possible to do this ``` post :foo, params: { user: User.first } # Prior to the patch the controller will receive { "user" => "1" } # Whereas now you get { "user": "#<User: ...>" } ``` The fix in this PR is to modify `Hash#to_query` to sort only when it doesn't contain an array structure that looks something like "bar[]" Ref rails#33341 (comment)
b177982
to
48b6bac
Compare
CI seems broken but unrelated. Try re-running without success (it fails fetching some ubuntu package) |
e4e1b62 broke `to_param` handling:
e4e1b62 broke `to_param` handling:
e4e1b62 broke `to_param` handling:
There was an issue inside controller tests where order params were not respected, the reason
was because we were calling
Hash#to_query
which sorts the results lexicographically.1e4e1b62 fixed that issue by not using
to_query
but instead a utility function provided by rack.However with the fix came another issue where it's now no longer possible to do this
The fix in this PR is to modify
Hash#to_query
to sort only when itdoesn't contain an array structure that looks something like "bar[]"
Ref e4e1b62 broke
to_param
handling: #33341 (comment)