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

Query().WithAll() #232

Closed
niondir opened this issue Aug 24, 2017 · 4 comments
Closed

Query().WithAll() #232

niondir opened this issue Aug 24, 2017 · 4 comments

Comments

@niondir
Copy link
Contributor

niondir commented Aug 24, 2017

When loading one entity and changing some value, the store.Update() method will delete all relations that are not loaded. Therefore one has to explicitly call all With**() methods.

If there isn't some other way to load an entity with all relations, or to save an entity without setting all relation to null I would suggest some method New**Query().WithAll() to load all related entities as well.

@roobre
Copy link
Contributor

roobre commented Aug 24, 2017

Relations being deleted when set to nil is actually a bug and not expected behaviour, as seen in related issues (#211). This should have been fixed with #214, but for some reason it's back to haunt us. I guess we'll need to wait for a fix.

As a workaraound, I just feed Update() the name of the fields I want to update explicitly.

You might want to edit the title to reflect the actual bug.

Last but not least, as setting the relation to nil won't actually delete the relationship when this is fixed, I've opened an issue (#219) to discuss if a set of functions to delete relations without touching the actual objects is something worth implementing (which I think it is).

@roobre
Copy link
Contributor

roobre commented Nov 22, 2017

Querying all relationships at once is probably a bad idea on most cases, so it makes no sense to me to expose this functionality that easy. Users willing to do this can easily chain all WithTYPE functions.

@roobre roobre closed this as completed Nov 22, 2017
@niondir
Copy link
Contributor Author

niondir commented Nov 22, 2017

It's definitely more about the saving part that must not set the not queried relations to nil.

@roobre
Copy link
Contributor

roobre commented Nov 23, 2017

The issue you mention (#211) has already been fixed (#214).

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

No branches or pull requests

2 participants