-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support specifying types #8
Comments
I've been debating myself how to handle specifying the types within odata-query. So far I've been considering 2 approaches:
import buildQuery, { format } from 'odata-query';
const query = { SomeProp: format(value, 'decimal') }
buildQuery({ filter }) I like this approach but it might be difficult to detect when passing in a "pre-typed" value as a string (ex.
import buildQuery from 'odata-query';
const query = { SomeProp: { decimal: value }}
buildQuery({ filter }) I'm not sure what the structure of this object should be, and I'm not overly keen on the key being the name of the formatter (although this somewhat aligns with the equality operators and boolean string functions). We would need a known list of formatters ahead of time, which would break supporting custom types (although I've not used them myself). It also seems like this approach adds more "magic" to the query format of odata-query. For reference, here is the list of types we need to support (there might be more):
|
We could also have an explicit value format: |
Starting in I would still like to support most of the types listed above (ex. |
How is it supposed to work with the The current implementation works with the buildQuery({
foo: {
eq: {
type: 'guid',
value: 'value'
}
},
bar: { in: {
type: 'guid',
value: ['bar1', 'bar2']
}
},
foobar: { in: [{
type: 'guid',
value: 'foobar'
}, {
type: 'guid',
value: 'barfoo'
}]
}
}) I implemented a solution for the in-operator (Commit). I don't know how you want to handle this case. |
@samuelportz all comparison operators except Your referenced fix looks good to me and would merge it in if you would send a PR. |
I think this is an oData v4 thing. Sample code: https://github.com/devnixs/ODataAngularResources/blob/master/src/odatavalue.js
The text was updated successfully, but these errors were encountered: