feat: combine equalTo clauses with clauses#1373
feat: combine equalTo clauses with clauses#1373sadakchap wants to merge 13 commits intoparse-community:alphafrom
Conversation
davimacedo
left a comment
There was a problem hiding this comment.
@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? |
| } | ||
|
|
||
| this._where[key] = encode(value, false, true); | ||
| // this._where[key] = encode(value, false, true); |
There was a problem hiding this comment.
This comment seems to be a leftover?
There was a problem hiding this comment.
Will update the pr once all checks are passing.
| expect(data).toEqual({ | ||
| limit: 1, | ||
| where: { | ||
| objectId: 'jobId1234', |
There was a problem hiding this comment.
Should all these tests be modified? That means the original syntax would not be tested anymore?
There was a problem hiding this comment.
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.
Could that be a breaking change for existing deployments?
There was a problem hiding this comment.
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.
Does this mean the query sent to the DB has a different syntax, or only the query sent to Parse Server?
| expect(q.toJSON()).toEqual({ | ||
| where: { | ||
| size: { | ||
| $eq: 'small', |
There was a problem hiding this comment.
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.
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, |
New Pull Request Checklist
Issue Description
equalToquery overrides any existing clauses before it. For e.g.Related issue: #
1372Approach
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