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 delete relation field when _Join collection not exist #864

Merged
merged 1 commit into from
Mar 6, 2016

Conversation

Marco129
Copy link
Contributor

@Marco129 Marco129 commented Mar 6, 2016

Fix for #848
Check for existence before dropping

@codecov-io
Copy link

Current coverage is 90.49%

Merging #864 into master will decrease coverage by -1.19% as of 76895e5

@@            master    #864   diff @@
======================================
  Files           71      71       
  Stmts         4102    4104     +2
  Branches       845     846     +1
  Methods          0       0       
======================================
- Hit           3761    3714    -47
  Partial         10      10       
- Missed         331     380    +49

Review entire Coverage Diff as of 76895e5

Powered by Codecov. Updated on successful CI builds.

@gfosco
Copy link
Contributor

gfosco commented Mar 6, 2016

Nice... Thanks! 👍

gfosco added a commit that referenced this pull request Mar 6, 2016
Fix delete relation field when _Join collection not exist
@gfosco gfosco merged commit fedeff9 into parse-community:master Mar 6, 2016
@@ -409,7 +409,11 @@ class Schema {

if (this.data[className][fieldName].startsWith('relation<')) {
//For relations, drop the _Join table
return database.dropCollection(`_Join:${fieldName}:${className}`);
return database.collectionExists(`_Join:${fieldName}:${className}`).then(exist => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Marco129 This is slightly racy. I don't expect people to be have many callers attempting to create and delete the same field many times, but I'd rather just avoid race conditions everywhere. Can you modify this to attempt the delete, and catch the error if the collection doesn't exist?

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.

5 participants