-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
Add related savings methods #415
base: master
Are you sure you want to change the base?
Conversation
The API seems good. I would probably change So if I'm not wrong the different failure points would be:
Maybe we could create a new method so that the record is automatically inserted if not saved already and then it updates the relation IDs. This method should be called Thoughts on this? |
If I understand it correctly
Correct? |
Yes, that is what I have understood from the tests @RomainMazB has made. About the delete part that seems the most reasonable thing as in order to delete the related record from the database, we should need to check that it is not related to other models first. Maybe @RomainMazB can clarify if we have understood this correctly? |
Have no thoughts on the API for now, I guess we'd want more input from users! Do have a thought in the implementation strategy. I don't think we should fiddle too much with the current We can try introduce one more layer of abstraction, a |
@RomainMazB pinged me on Discord about this, so I'll give my input fwiw. I like @PauMAVA's suggestion on renaming As for deletions, I'm thinking that in this context deletions are deletions of the relation, not of the related object. So if I have a many-to-many relation between bakeries and cakes, the fact that I removed the relation between a bakery and a cake does not mean I need to remove the cake. Removing the related object is probably something that should be done explicitly. Something like that, anyway. Finally, the suggestion to implement an additional abstraction layer to implement these relations, I'm not sure about that, if I may be so frank. I like my ORMs smart, powerful and simple. I use them for convenience reasons. Additional layers of abstraction might make an ORM smarter and more powerful, but not necessarily simpler. When I started with programming, I used to use the ORMs that came with Django and Rails. Different times, for sure, but in terms of relation management, I like what they do. Simple, powerful API, implemented directly on the models themselves and smart. I think the suggested API comes reasonably close to that, so I would be happy with this. Anyway, I'm an amateur, so I might get this all wrong ;) |
7ce941b
to
33a87d7
Compare
Reviving this old PR ✌🏻.
To me, the
To clarify my vision, this is why I used To keep it clear and remind an up-to-date API, here is the list of the methods that would be added.
|
This PR will adds an easier way to save related models, without having to pay attention to fill the id of the related model.
It will take some time to be implemented, but I already submitted it as a draft-PR so we can discuss about the API.
API