-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add null value filter #1721
base: alpha
Are you sure you want to change the base?
Conversation
Thanks for this PR. In MongoDB, the value
That means from a MongoDB perspective there may not be a difference between the Parse Dashboard filters "does not exist" and "is null". To unambiguously query for objects with a field of content The distinction in MongoDB is:
Your video shows a filer for Another aspect to consider is how that plays with the Postgres adapter, or whether that is something unique to MongoDB. |
True. That's why we are filtering for both exists & equal to null value. If filtering field is
Could you please elaborate? I don't think I understand the question properly. |
Do you mean that is how you personally use the filter to query for a)? It may return the same results, but the correct - because more efficient - query for this is:
|
yes.
Yes, you are correct! But, How do I send a query like this, I searched in the docs but couldn't find anything that would query on type of the field. |
Not sure whether Parse Server supports this yet, you would have to look into the code, it may exist but not be in the docs. Therefore I suggest this naming to make them distinguishable: a) If later someone adds filter (a), they can name the filter |
I look into this file, but I couldn't find any thing that would query on type.
Sounds good 👍, so should I change the current query as well for query.exists(field);
let nullQuery = new Parse.Query(className);
nullQuery.equalTo(field, null);
query = Parse.Query.and(query, nullQuery); to query.equalTo(field, null) as the current query fetches records only with |
Yes I think so. Can one still query only for null values by adding the field exists filter additionally for the same field in the dashboard? |
I think only one filter is allowed on a field at a time. No, I don't think it is possible. |
You could additionally add the If it really isn't possible, then you could add this:
with a comment that this is a workaround because Then we could have both filters (is null; does not exist or is null) in the dashboard with this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sadakchap Thanks for the PR! I was the one who requested it.
@@ -104,6 +104,9 @@ function addConstraint(query, filter) { | |||
case 'keyLte': | |||
addQueryConstraintFromObject(query, filter, 'lessThanOrEqualTo'); | |||
break; | |||
case 'dneOrNull': | |||
query.equalTo(filter.get('field'), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this query will return null values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it will also include records which does not have filter field even set, that's why the name of filter does not exits or null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good
I think only one filter is allowed on a field at a time.
You can set composable to true if you to do multiple filters on a field. Similar to how less than does it. (Perhaps we should document these)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling composable is a good idea.
Regarding the commented code here, the difference is the MongoDB performance. The current query is an explicit "does not exist or is null" conditional, without $and
. This distinction is also relevant for indexing.
Enabling composable and add this filter query allows for both ways, so that's the most versatile way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean document composable
and comparable
it usually takes a while to figure out what they mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sends where={age:{$exists: true}}
if you set a combined filter of (1) and (2)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sends where={age:{$exists: true}} if you set a combined filter of (1) and (2)?
yes.
I think that's strange as, for let's say 2 filters less than
& exists
, we do something like
query.lessThan(field, compareTo); // compareTo is value entered by user to which s(he) wants to compare
query.exists(field);
This sends a query like where={age: {$lt: 4, $exists: true}}
Then, why not this
query.equalTo(field, null);
query.exists(field);
sends a query like where={age: {$eq: null, $exists: true}}
.
I tried searching in thee docs about equalTo
query, whether it is composble or not. But, there's nothing about that 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dplewis when you mentioned composable
, on what level did you mean that? On a MongoDB level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a limitation with MongoDB rather it's with JS Sdk.(just an opinion)
As when I explicitly(using cURL) make a request with where={age: {$exists: true, $eq: null }}
, it does return records only with null
field value.
But, when I'm trying to couple $exists
& $eq
query, it only sends request with where={age: {$exists: true}}
.
I'm trying this way to construct the query
query.equalTo(field, null);
query.exists(field);
Maybe I'm missing some point with js sdk. Would really appreciate any help with creating a query with where={age: {$exists: true, $eq: null }}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new issue for this parse-community/Parse-SDK-JS#1372.
@sadakchap Do you think we can resolve any open questions here? I think this PR is almost ready for merge, it would be great to have it in the upcoming release of Parse Dashboard. |
This pr was originally to add a feature through which users can filter records with only But, we decided to add a filter I also raised an issue in Parse-SDK-JS. But, I think I am really not the right person to solve this issue. For this feature, maybe we can try coupling |
@sadakchap So maybe we can finalize this PR like this:
What do you think? |
Thanks @mtrezza . I was working on this issue's PR. I was able to to clear all unit test cases. Right now, I think only LiveQuery Integration test cases are failing. I know that, this is open from long time, but If we can wait just 1 more week ( so that I can try to fix those failing integration test cases). It would be really nice. Or else we can do as you have suggested(incase it takes more than a week). |
Sure. Let's wait as you suggest. |
For Postgres, the server treats |
Feature request #1658
Added new filter to filter records if field contains
null
value.