-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(DatabaseController): Do not match searching for null in relation #3924
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.
Thanks for the fix, I have a small suggestion to keep the code a bit more readable, even we could extract in a local function the query[key] -> queries mapper to improve readability
relatedIds | ||
} | ||
}); | ||
const queries = query[key] == 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.
We should probably break that on more lines (as we do for the first early exit), quite tough to read.
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 improved little bit the code so it will handle more cases
Also, the issue still persists on postgres, can you address it please? |
Codecov Report
@@ Coverage Diff @@
## master #3924 +/- ##
==========================================
+ Coverage 90.51% 90.54% +0.02%
==========================================
Files 114 114
Lines 7686 7699 +13
==========================================
+ Hits 6957 6971 +14
+ Misses 729 728 -1
Continue to review full report at Codecov.
|
Fixed for Postgres. It was actually crashing when passing null values. Null values were not working even for simple queries (https://github.com/parse-community/parse-server/pull/3924/files#diff-f06f950a126bc6349f0e579b6ef362f7R26 and https://github.com/parse-community/parse-server/pull/3924/files#diff-f06f950a126bc6349f0e579b6ef362f7R52). There were some problems when creating the sql queries and also when saving null data (https://github.com/parse-community/parse-server/pull/3924/files#diff-b0af2ee2c26859a8aa6d8d0a0cf3a64aR779). |
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.
Thanks for the fix for null types in Pg, that was clearly overlooked, and not covered at all! Can you address the 2 small comments and we’ll get that one in too!
spec/ParseQuery.spec.js
Outdated
@@ -52,6 +106,9 @@ describe('Parse.Query testing', () => { | |||
|
|||
var relDislike1 = cake1.relation("hater"); | |||
relDislike1.add(user2); | |||
|
|||
cake1.relation("something"); |
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.
Is it needed?
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.
Not needed. Jut removed.
if (!t || t.type !== 'Relation') { | ||
return Promise.resolve(query); | ||
} | ||
let queries = [{isNegation: false, relatedIds: []}]; |
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.
Why do we initialize non empties?
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 is the trick that solves the problem. When it is null and not match this (https://github.com/parse-community/parse-server/pull/3924/files#diff-26b0f888e8a20f22d9728a26272f6cddR624), we need to pass relatedIds empty, otherwise it will be ignored. I changed little bit the code. Take a look if it is more clear now.
…ll in relation field
Done. |
Fix #3923