Improve beforeSave triggers for newly created objects. #619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request does a lot of things, but is setup in this way to showcase the full story on why we need these:
This fixes the following issues:
dirtyKeys()
inbeforeSave
hook for newly created objectsbeforeSave
hook for the root object.Improvements:
Changes:
_Session
class is no longer supported, and actually shouldn't be, since it's quite scary for security, easy to mess up as well as this is not something new and it was explicitly was never supported (Parsers - D9140 for reference on the initial restriction).Fixes #589
Outside of obvious improvements - here is the broader explanation on why we need to remove support for _Session, at least for now:
dirtyKeys()
,isNew()
and friends.set()
on a Parse.Object instance, as this is what the API allows us.We can plan to support triggers on sessions, but I think they shouldn't be allowed, since they introduce a lot of hidden complexity in the first place and could be a giant failure point for any application, if anything goes wrong in them.
cc @gfosco