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
{{ message }}
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.
Query parameters in uris allow keys to be repeated. It would be nice if this were supported as many services make use of this, e.g. default query param parsing in PHP and ring.middleware.params.
I propose that if the value in query map is a seq, repeat the key in the serialized uri for each value in the seq. Likewise on deserialization emit a vector of values for the key.
The problem with this is that the cardinality of query param values in parsed urls will depend on the query string.
Other approaches I've seen paper over this difference by using a custom type that pretends all keys have scalar values unless you do something special to ask for the other values for a key (e.g. many Python libraries use a "MultiDict" with a special .getall(k) method). This could be done in clojure with a custom type for query parameters that returns the last seen value for lookups, but has some extra protocol that returns a vector. (However if you go down this route you no longer have a simple library.)
Another possibility is to force the user to be explicit about which query params are cardinality-many. This could be done with different url functions, examples:
Right, so we actually need to work with multimaps. I don't think a special type is necessary, or helpful in this case. I'm happy to have params that have a single value be represented with just a string; no need for single-element vectors. I'm not sure of the value of allowing some kind of filter function as a param to url.
(This is a strawman proposal.)
Query parameters in uris allow keys to be repeated. It would be nice if this were supported as many services make use of this, e.g. default query param parsing in PHP and ring.middleware.params.
I propose that if the value in query map is a seq, repeat the key in the serialized uri for each value in the seq. Likewise on deserialization emit a vector of values for the key.
E.g.
The problem with this is that the cardinality of query param values in parsed urls will depend on the query string.
Other approaches I've seen paper over this difference by using a custom type that pretends all keys have scalar values unless you do something special to ask for the other values for a key (e.g. many Python libraries use a "MultiDict" with a special
.getall(k)
method). This could be done in clojure with a custom type for query parameters that returns the last seen value for lookups, but has some extra protocol that returns a vector. (However if you go down this route you no longer have a simple library.)Another possibility is to force the user to be explicit about which query params are cardinality-many. This could be done with different url functions, examples:
Thoughts?
The text was updated successfully, but these errors were encountered: