8000 Update() destroys existing second-level relationships · Issue #211 · src-d/go-kallax · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update() destroys existing second-level relationships #211

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
nadiamoe opened this issue Jul 28, 2017 · 2 comments · Fixed by #214
Closed

Update() destroys existing second-level relationships #211

nadiamoe opened this issue Jul 28, 2017 · 2 comments · Fixed by #214

Comments

@nadiamoe
Copy link
Contributor

Looks like Person.Save() saves only first level relationships, just like the README says. However, second-level relationships are destroyed if they already exist.

The most inmediate fix would be to avoid this behaviour, making Update() ignore second-level relationships instead of deleting them.

As, in most cases, one would want to change just the relationship itself and not the whole depending object, a plain Update() function may be appreciated.

In fact, I think the case where you want to edit an object and its relatives in the same operation is fairly common for insertions, but relatively rare for updates. So making this new "plain update" the default behaviour and delegating the current "full update" operation to a different method might be worth considering.

@erizocosmico
Copy link
Contributor
erizocosmico commented Aug 1, 2017

Thanks for reporting this! We'll look into this issue as soon as we can.

Because of the breaking changes, it can not be default behavior until 2.0, but we can add a UpdateOnly or something like this.

@erizocosmico
Copy link
Contributor

NOTE: Reproduction case has been merged in fix/save-relations. The bug will be fixed in that branch and then PR'd.

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

Successfully merging a pull request may close this issue.

2 participants
0