Closed michael-dean-haynie closed 2 years ago
Are quotes around strings necessary?
@justinbmeyer - sorry missed this.
For the IBM style, the quotes distinguish "constant values" from null
or other attribute references (column names).
Examples:
?filter=contains(name,'anna')
?filter=not(equals(lastName,null))
?filter=greaterThan(wins,losses)
We might be able to get rid of the quotes with minimal issues. Personally I think they are helpful for clarity, though.
https://www.jsonapi.net/usage/reading/filtering.html
the biggest issue would be distinguishing attribute references (column names) from string values. We'd have to be able to check the data models. Or come up with an alternative convention (like a prepended '#' for attribute references)
There are a couple areas in the filter parsers that could use some more testing/development:
The IBM-Style parser
any
operator should not accept operands of different types. For example:filter=any(age,'1','2','3')
filter=any(age,'1','2','cat')
orfilter=(age,'1','2','2020-01-01')
filter=any(age,'1','2',null)
(nulls can be mixed in with other types)The MongoDB-Style parser could probably use more tests to confirm expected behavior when array notation and omitted operators are mixed. Some examples:
filter[name]='brad'&filter[name][$eq]=josh
filter[age][$eq]=10&filter[age]=11,12,13
As for what the expected behavior actually is ... probably whatever makes sense once it's been looked into.