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 dirtyKeys() and dirty(key:) on beforeSave when updating objects. #614

Merged
merged 4 commits into from
Feb 24, 2016

Conversation

nlutsenko
Copy link
Contributor

Properly reconstruct the full object by applying values one-by-one to the original object if it's an object update.
There is another small piece missing - removing support for _Session triggers, which will unblock us on using the same approach for re-constructing dirtyKeys() on object creation in beforeSave().

Fixes #581, fixes #419

it('test beforeSave get dirtyKeys on update', function(done) {
var triggerTime = 0;
// Register a mock beforeSave hook
Parse.Cloud.beforeSave('GameScore', function(req, res) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this going to interact with cloud code in other tests? If every cloud code test is modifying some global that seems like it could get messy fast.

@drew-gross
Copy link
Contributor

Up to you if you want to do anything about that test comment.

@natanrolnik
Copy link
Contributor

This should close #581 and #419

@nlutsenko
Copy link
Contributor Author

@natanrolnik Yup, know about #581, but missed #419. Thanks, attaching the other one to the PR, so it's automatically closed when this is merged.

@nlutsenko
Copy link
Contributor Author

Updated a little bit - the core logic didn't change, but unified all tests into a single describe() to be able to add before/after test to make sure we delete everything we setup.
Also, for a strange reason - had to enable strict mode so ES6 gets picked up. ¯_(ツ)_/¯

@facebook-github-bot
Copy link

@nlutsenko updated the pull request.

@drew-gross
Copy link
Contributor

I'm not 100% sure, but I believe what is actually happening with use strict is that babel isn't applying to the tests, so use strict is enabling whatever fraction of es6 is supported natively in node, and that happens to be enough for this file.

@nlutsenko
Copy link
Contributor Author

Huh, that might be true actually... Weird.

nlutsenko added a commit that referenced this pull request Feb 24, 2016
Fix dirtyKeys() and dirty(key:) on beforeSave when updating objects.
@nlutsenko nlutsenko merged commit 1ae61c9 into master Feb 24, 2016
@nlutsenko nlutsenko deleted the nlutsenko.beforeSave.dirty branch February 24, 2016 06:35
@btate
Copy link

btate commented Feb 24, 2016

Any idea when this will be in a tagged release so our package.json will pick it up?

@drew-gross
Copy link
Contributor

Probably today or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants