You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when taking query parameters into account, the comparison seems to be ordered (while I would expect the order of query parameters to have no impact). See:
I solved the issue with a bit of monkey patching, but is there a reason for having an ordered comparison here?
My solution:
defquery_params_dict_eq_monkey_patch(self, other):
""" >>> a = boltons.urlutils.URL('http://example.com/foo, bar?foo=bar&bar=foo') >>> b = boltons.urlutils.URL('http://example.com/foo%2C%20bar?bar=foo&foo=bar') >>> a == b True """returndict(self) ==dict(other)
boltons.urlutils.QueryParamDict.__eq__=query_params_dict_eq_monkey_patch
Thanks!
The text was updated successfully, but these errors were encountered:
Thanks for the detailed report! I'm fairly certain that by the standard, query parameter order is significant. In practice, when query parameters are all unique, an unordered dict is almost always a sufficient representation. However, multiple values for the same key are sometimes turned into/treated as a list of values, and the natural significance of order is a lot more apparent there. That's the reason URL uses an OrderedMultiDict instead of a normal dict.
Still, I think you've got a valid use case. Have you considered subclassing URL and adding your __eq__ there instead?
Hi,
I am using
boltons
to do URL comparisons, being agnostic of the URL representation, and it works great so far except for query parameters.Typically, with percent encoding, this is working as expected:
However, when taking query parameters into account, the comparison seems to be ordered (while I would expect the order of query parameters to have no impact). See:
I solved the issue with a bit of monkey patching, but is there a reason for having an ordered comparison here?
My solution:
Thanks!
The text was updated successfully, but these errors were encountered: