-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Adding $nor operator support #4768
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
Conversation
@jeremypiednoel Go for it! Let me know if you need anything. |
@dplewis I'm very noob in postgresql. So let's see if i can figure out |
Very nice! We'll need to add some docs as the logical explanation is not trivial for a non seasoned developer. |
Btw am i the only one to have pb with |
@jeremypiednoel did you pull the latest master& this should be good now. |
see the latest commit it's a |
@jeremypiednoel That issue was fixed minutes ago #4767 |
@dplewis very true i had to commit the file first to pull the upstream then. |
@dplewis how can i specify i want the test to run on postgresql ? |
Thanks ! i'll try to make it work |
@jeremypiednoel If you want to cheat you can find a solution on my branch for PG. https://github.com/dplewis/parse-server/tree/nor-op You will still need test for empty $nor array (I know that mongo and pg throws an error for nonempty $or, $and, $nor) and a test for invalid nor (not array) |
thnaks @dplewis i'm gonna check that after lunch ! |
Codecov Report
@@ Coverage Diff @@
## master #4768 +/- ##
==========================================
- Coverage 92.68% 92.64% -0.05%
==========================================
Files 119 119
Lines 8659 8663 +4
==========================================
Hits 8026 8026
- Misses 633 637 +4
Continue to review full report at Codecov.
|
@dplewis can you take a look ? |
spec/ParseQuery.spec.js
Outdated
@@ -2567,6 +2567,48 @@ describe('Parse.Query testing', () => { | |||
}); | |||
}); | |||
|
|||
it('$select inside $nor', (done) => { |
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.
Change the name as $select
isn't being used here
spec/ParseQuery.spec.js
Outdated
obj.save().then(() => { | ||
return rp.get(Parse.serverURL + "/classes/TestObject", options); | ||
}).then(done.fail).catch((error) => { | ||
equal(error.error.code, Parse.Error.INVALID_JSON); |
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 be INVALID_QUERY
.
@@ -62,7 +62,7 @@ const validateQuery = (query: any): void => { | |||
} | |||
|
|||
if (query.$or) { | |||
if (query.$or instanceof Array) { |
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.
Revert these changes to $or
and $and
as are they are causing tests to fail.
They also have nothing to do with the PR.
spec/ParseQuery.spec.js
Outdated
}); | ||
}); | ||
|
||
it('$nor invalid query', (done) => { |
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.
Maybe another test when $nor: 1234
(non array)
Thanks for the feedback, it's fixed i'll fix the minimum size of the $and and $or in another PR according to the mongo doc
|
const clauses = []; | ||
const clauseValues = []; | ||
fieldValue.forEach((subQuery) => { | ||
const clause = buildWhereClause({ schema, query: subQuery, index }); | ||
if (clause.pattern.length > 0) { | ||
if (fieldName === '$nor') { | ||
clause.pattern = `(NOT ${clause.pattern})`; | ||
} |
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.
you're doing (NOT query1) AND (NOT query2)
instead of NOT (query1 OR query2)
whhich tecnically work but can be a bit misleading for maintenance. Can« you document it or revert the logic with the help of line 323? Event if it's the same, rtaht will help for comprehension in the future ;)
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 I was pretty lazy 😅
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.
Yeah I figured it worked but letMs write it cleanly please
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'll fix 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.
A small nit for maintainability :)
@flovilmart @dplewis i reverted the logic. |
@jeremypiednoel thanks for the changes, looking good, waiting for the CI. |
@flovilmart do you think it makes sense to add the array.length test on $end and $or conditions ? |
Let’s not change it now, as it would be a breaking change for the clients (change in behavior) that yield an error instead of returning results. |
* adding nor to specialQuerykeys * adding nor suport * adding test * CRLF * adding postgres NOR * adding nor validation * adding NOR test * adding test amd fixing NOR cases * revert the nor logic
@dplewis tell me if you want me to investigate on postgresql !