Skip to content
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

Merged
merged 1 commit into from
Jun 21, 2017

Conversation

davimacedo
Copy link
Member

Fix #3923

Copy link
Contributor

@flovilmart flovilmart left a 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 ?
Copy link
Contributor

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.

Copy link
Member Author

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

@flovilmart
Copy link
Contributor

Also, the issue still persists on postgres, can you address it please?

@codecov
Copy link

codecov bot commented Jun 19, 2017

Codecov Report

Merging #3924 into master will increase coverage by 0.02%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/Controllers/DatabaseController.js 94.36% <100%> (+0.01%) ⬆️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.15% <93.75%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16954c2...4f5b6a9. Read the comment docs.

@davimacedo
Copy link
Member Author

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).

Copy link
Contributor

@flovilmart flovilmart left a 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!

@@ -52,6 +106,9 @@ describe('Parse.Query testing', () => {

var relDislike1 = cake1.relation("hater");
relDislike1.add(user2);

cake1.relation("something");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

Copy link
Member Author

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: []}];
Copy link
Contributor

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?

Copy link
Member Author

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.

@davimacedo
Copy link
Member Author

Done.

@flovilmart flovilmart merged commit a0d1a35 into parse-community:master Jun 21, 2017
@flovilmart flovilmart modified the milestone: 2.5.0 Jun 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants