bitovi / querystring-parser

MIT License
8 stars 5 forks source link

Improve filter tests #18

Closed michael-dean-haynie closed 2 years ago

michael-dean-haynie commented 2 years ago

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:

The MongoDB-Style parser could probably use more tests to confirm expected behavior when array notation and omitted operators are mixed. Some examples:

justinbmeyer commented 2 years ago

Are quotes around strings necessary?

michael-dean-haynie commented 2 years ago

@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)