Skip to content

Option to prevent cascade saving #864

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

Closed
RaschidJFR opened this issue Jul 14, 2019 · 7 comments · Fixed by #881
Closed

Option to prevent cascade saving #864

RaschidJFR opened this issue Jul 14, 2019 · 7 comments · Fixed by #881
Assignees
Labels
type:feature New feature or improvement of existing feature

Comments

@RaschidJFR
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When saving an object in which properties there's a pointer to another object, the SDK launches a batch operation to save all modifications made to all nested objects, which is great but... when you don't have write access to any of those (for example when you're saving a Message object pointing to another user's profile) you need to make sure nested objects are not dirty or call rever() in order not to get the Object not found error.

Describe the solution you'd like
A parameter in the saving options, something like ParseObject.save(null, {cascadeSave: false}) would address this issue.

Describe alternatives you've considered
A workaround for now is to call Parse.Object.revert() on all objects to which you know this user does not have write permissions.

@davimacedo
Copy link
Member

@RaschidJFR would you be willed to tackle this one?

@RaschidJFR
Copy link
Contributor Author

I'd love to but currently I've got my hands full. Hopefully I'll work on the docs next week. If this task is still untaken by then I will take it.

@RaschidJFR
Copy link
Contributor Author

Is this still untaken? I’m taking it

@RaschidJFR
Copy link
Contributor Author

Hey guys. So I've implemented this option, but as I was discussing with @davimacedo , we need to make sure this parameter's scope is clear.

What I intend to do here is give an option not to save the whole chain of nested objects when you call Parse.Object.save(), so you don't get data saved which you didn't explicitly intended to, just the object on which you called the function.

I think it is important that new objects always get saved despite this parameter's value in order to keep the relational data and leverage the simplicity of the default behaviour, which is great.

Opinions?

P.S. take a look at the test case so you can clearly understand the proposed behaviour

davimacedo pushed a commit that referenced this issue Aug 7, 2019
* feat(ParseObject): Add option `cascadeSave` to save()

Closes #864

* fix(ParseObject): Safe check for unsaved in save()

* refactor(ParseObject): `cascadeSave` won't save new objects

Nested objects who have not been saved will be ignored when setting `cascadeSave: true`, so save() will throw "Cannot create Pointer to an unsaved ParseObject".
@RaschidJFR
Copy link
Contributor Author

Related to this, I've noticed that Parse.Object.revert() affects also nested objects, same way. Do you think it's worth opening an issue for it?

@davimacedo
Copy link
Member

Are sure it affects the nested objects? Could you write a test case?

@RaschidJFR
Copy link
Contributor Author

False alarm. It does not affect nested objects.

@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants