-
-
Notifications
You must be signed in to change notification settings - Fork 594
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: combine equalTo clauses with clauses #1373
base: alpha
Are you sure you want to change the base?
Conversation
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 do you mind to look at the failing tests?
Overall I like the idea. @dplewis what do you think?
@sadakchap it seems you have actually also added the fix in this PR, correct? If so, is this ready for review? I would like to add the related dashboard feature with the null filter. |
Thanks @mtrezza , I think it still has some failing tests. I will try to fix those during this weekend and will let you know 🙂 |
Thanks for opening this pull request!
|
@mtrezza Thanks for following up & waiting. About failing test cases. Only Live Query test are failing as they depend on parse-server to fire events. We will need to update parse-server to send events for |
Here's the pr with added support for @mtrezza @davimacedo @dplewis, would really like to hear your thoughts about it? |
@@ -1222,7 +1222,8 @@ class ParseQuery { | |||
return this.doesNotExist(key); | |||
} | |||
|
|||
this._where[key] = encode(value, false, true); | |||
// this._where[key] = encode(value, false, true); |
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.
This comment seems to be a leftover?
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.
Sure, will remove.
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.
Will update the pr once all checks are passing.
@@ -301,7 +301,9 @@ describe('CloudController', () => { | |||
expect(data).toEqual({ | |||
limit: 1, | |||
where: { | |||
objectId: 'jobId1234', |
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.
Should all these tests be modified? That means the original syntax would not be tested anymore?
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.
Yes, all test are modified. And yes, original syntax would not be tested anymore as it will always make any equalTo query with this updated syntax { $eq: '' }
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.
Could that be a breaking change for existing deployments?
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 see it as a breaking change, as it will just change the syntax of query for equalTo
, everything else should be same.
For adding equalTo
query, we still would be doing same thing.
q.equalTo('age', 10); // same implementation, just query that will be sent is of new syntax.
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.
Does this mean the query sent to the DB has a different syntax, or only the query sent to Parse Server?
@@ -136,6 +140,7 @@ describe('ParseQuery', () => { | |||
expect(q.toJSON()).toEqual({ | |||
where: { | |||
size: { | |||
$eq: 'small', |
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 seems strange that this results in $eq:small and $exists:false, isn't that a contradiction?
The comment assumed: equalTo('key', undefined) resolves to 'does not exist'
But in this case it just adds dne to the query, which probably results in a different query sent to the DB?
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.
Yes, It is contradiction. 😕
Suggestion: Maybe we can make $exists
override $eq
clause.
Problem: this pr is in response to this #1372, which was created due to this pr, where we were trying to make a query something like this(for filtering values which are null & exists)
where: { age: { $eq: null, $exists: true } }
which again won't be possible if $exists
can't be combined with $eq
stock: true, | ||
size: { | ||
$eq: 'medium', | ||
$exists: false, |
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.
This also looks strange
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.
New Pull Request Checklist
Issue Description
equalTo
query overrides any existing clauses before it. For e.g.Related issue: #
1372
Approach
After following through #1372 and parse-community/parse-php-sdk#476 and #1372 (comment).
Using
this.addCondition(key, $eq, value)
insteadthis.where[key]
, so that equalTo clause can be combined with other clauses and vice-versa.TODOs before merging