-
Notifications
You must be signed in to change notification settings - Fork 556
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
Keep query values data type when sorting #318
Keep query values data type when sorting #318
Conversation
Query values can be an array when the :flat_array notation option is used on the query mapper, so this conversion to hash is removing repeated query params (which can exist). This is a fix for #227
Thank you for this fix! How can one set flat_array notation on query mapper if WebMock api doesn't offer this option? In order to pull this request without any additional work on my side, I'd need unit test + acceptance test. |
Only after reading sporkmonger/addressable#77 did I understand the query mapper in use was borrowed from a previous version of Addressable (which provided the option), for backward compatibility reasons. I now added a commit with WebMock configuration variable that you can set globally in your code, or when using I had to dig this rabbit hole but I'm not really into the details of WebMock, so is this the proper way of doing it? |
For params specified multiple times all but the last value is ignored. Issue #227
Adding this option to allow_net_connect and disable_net_connect doesn't make sense, as it's not related to them in any way. I'd add a separate method to the api. |
@tjsousa do you plan any more work on this pull request or is it complete? |
It was meant to be for up review again with those last two commits passing on Travis CI. At the moment, I don't have much time for additional work on this one. Do you think it is useful for now? |
This particular issue affects me with a 3rd party API I have to work with. The API accepts duplicate querystring parameters. I'd appreciate if this could be merged in and am happy to assist in any way if this is needed. Right now I'm pointing my Gemfile to the fixed version from @tjsousa |
Spent an hour trying to figure out why the URL WebMock is reporting does not contain my query parameters. This is the URL (note the multiple occurences of
These are the parameters with CGI.parse (note the array for
And this is the URL that WebMock is reporting (note the single occurence of
What is the main reason this doesn't work out of the box and does this PR address it? Is it something that would possibly introduce a backwards incompatibility, perhaps for people who have stubbed their request based on what WebMock said, which is in fact an incomplete URL as their URL contains multiple parameters with the same name, and now these stubs would suddenly start failing? Anyway, I'd be interested in doing any additional work that needs to be done to get this merged. |
… and then because of the way this works, i.e. using multiple instances of the fq parameter, going through and fixing all existing PLOS Solr specs/mocks, because WebMock does not support multiple parameters with the same name (bblimke/webmock#318 (comment)).
@jure "What is the main reason this doesn't work out of the box" - the default notation used to serialize/deserialize urls is subscript and it doesn't support duplicate parameters names. The one that supports it :flat_array, is incompatible with :subscript The changes are now merged. You can do the following to support duplicate keys in parameters.
|
Fantastic! Thank you. |
Query values can be an array when the :flat_array notation option is used on the query mapper, so this conversion to hash is removing repeated query params (which can exist).
This is a fix for #227