kinto
kinto copied to clipboard
Add support for JSON format for in_ and exclude_ filters values
Historically in_
and exclude_
filters are comma separated only.
When we introduced contains_
and contains_any_
we decided to support JSON objects.
I think we should backport the logic to in_
and exclude_
or at least supports it for arrays of strings.
Refs https://github.com/Kinto/kinto-http.py/issues/187
I spent a little while trying to track down the history here. I think it's just an oversight. The main issue with supporting JSON values was in the storage code rather than the query deserialization code -- see https://github.com/Kinto/kinto/pull/1258. Then, when contains_
and contains_any_
were added in https://github.com/Kinto/kinto/pull/1604, but the behavior of in_
and exclude_
was left as-is. The code right now:
https://github.com/Kinto/kinto/blob/593abdbc15c358590c799b8d86461563da8efbe2/kinto/core/resource/schema.py#L231-L247
This aaaalmost works. A JSON array like ["a","b","c"]
gets split into ["a"
, "b"
, and "c"]
. Then we deserialize each element, but since the first and third aren't JSON, only the middle one gets deserialized correctly. That's why the strange behavior @Natim saw in his bug report.
The existing behavior can remain as a fallback AFAICT. We should just try native_value
first.