-
Notifications
You must be signed in to change notification settings - Fork 28
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
Filter by 'null' value is not taken in consideration #48
Comments
Until it's implemented, you can somewhat workaround it by overriding the data provider and modifying the filter object (e.g. I had a situation where const dataProvider = useDataProvider(...)
const customDataProvider: LegacyDataProvider = (type: string, resource: string, _params: any) => {
// clone params so we don't mutate input
const params = { ..._params }
// custom filter - field "effectiveInRange" doesn't exist
if (type === GET_LIST && resource === 'Entity' && params.filter.effectiveInRange) {
const targetDate: string = params.filter.effectiveInRange
delete params.filter.effectiveInRange
params.filter = {
...params.filter,
OR: [
// situations where effectiveTo is defined
{
effectiveFrom_lte: targetDate,
effectiveTo_gte: targetDate,
},
// when effectiveTo is null
{
effectiveFrom_lte: targetDate,
// we have to specify the equals, `effectiveTo: null` converts it to new Date(null) = 1.1.1970
effectiveTo: {
equals: null
}
}
]
}
}
return dataProvider(type, resource, params)
} |
can you check again with newest version? i just merged a PR #60 but i am not sure if it solves your problem |
The PR probably fixed only where it's in the NOT, OR or AND operators. In my case, effectiveTo: {
equals: "1970-01-01T00:00:00.000Z"
} |
@sMteX would be awesome if you could send a PR that fixes it! |
Once I have a bit more time I could potentially take a look at that, until then field: {
equals: null
} fortunately works |
https://github.com/panter/ra-data-prisma/blob/master/packages/dataprovider/README.md#custom-filters should also work around this! |
Dataprovider queries do not take into consideration a filter with
null
value which is stripped and excluded from the final query sent to the server.The text was updated successfully, but these errors were encountered: