nested filter query null issue
hello if I entered in the search bar a phone number while am saying the filtering query is uuid_user_id.phone what happens is all the records stays the same but the records of people who should not be returned are returned but null so I have the same number of records but some of them are null I will give you and example
here is my raw data returned from db:
[
{
"branch_id": 1,
"id": 5,
"role_id": {
"id": 1,
"name": "Parent"
},
"uuid_user_id": {
"email": "x1@gmail.com",
"id": "09150311-f672-4a9c-af0c-b150c8a64d0a",
"phone": "0114xxxx"
}
},
{
"branch_id": 1,
"id": 6,
"role_id": {
"id": 2,
"name": "Teacher"
},
"uuid_user_id": {
"email": x2@gmail.com",
"id": "a3ef5c76-3d58-4340-8f16-a0721eb2e286",
"phone": "0102xxxx"
}
},
{
"branch_id": 1,
"id": 7,
"role_id": {
"id": 3,
"name": "admin"
},
"uuid_user_id": {
"email": "x3@gmail.com",
"id": "fa768d1d-2b57-48be-b91b-6d3d1f03f980",
"phone": "01515"
}
},
]
and below is the filtered data after i entered 011
[
{
"branch_id": 1,
"id": 5,
"role_id": {
"id": 1,
"name": "Parent"
},
"uuid_user_id": {
"email": "x1@gmail.com",
"id": "09150311-f672-4a9c-af0c-b150c8a64d0a",
"phone": "0114xxxx"
}
},
{
"branch_id": 1,
"id": 6,
"role_id": {
"id": 2,
"name": "Teacher"
},
"uuid_user_id": null
},
{
"branch_id": 1,
"id": 7,
"role_id": {
"id": 3,
"name": "admin"
},
"uuid_user_id": null
},
]
you will find they are the same just some records has uuid_user_id = null
2 Replies
Hi @antably. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, I don't have enough specific details to fully explain why you're seeing this particular behavior with nested filter queries and null values in your case. However, I can provide some general insights and potential solutions related to filtering and null handling in refine.
1. Handling null values: Some data providers in refine have specific ways to handle null values in filters. For example, the Hasura data provider supports
null
and nnull
operators for filtering null values Github Issue #4972 (https://github.com/refinedev/refine/issues/4972).
2. Nested filters: Refine supports nested filters in some data providers. For instance, the Supabase data provider had an issue with nested CrudFilters that was later resolved Github Issue #3451 (https://github.com/refinedev/refine/issues/3451).
3. Data provider customization: If the default behavior of your data provider doesn't meet your needs, you can customize it. As mentioned in Github Issue #6423 (https://github.com/refinedev/refine/issues/6423), you can handle null return values in your data provider's getList
method.
4. Dot notation for nested fields: Some data providers support dot notation for filtering nested fields. For example, the Hasura data provider implemented this feature Github Issue #2320 (https://github.com/refinedev/refine/issues/2320).
Given your specific issue, it seems that the filter is being applied, but instead of removing non-matching records, it's setting the uuid_user_id
field to null for those records. This behavior is not standard and might be specific to your data provider or backend implementation.
To resolve this, you might need to:
1. Check your data provider implementation and ensure it's correctly handling nested filters.
2. Verify if your backend API is correctly processing the filter parameters.
3. Consider customizing your data provider to handle this specific case.
If you're using a specific refine data provider and need more detailed help, you might want to open an issue on the refine GitHub repository with your specific data provider and configuration details.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@426148142124236810> Kapa.ai is still learning and improving, please let me know how I did by reacting below.