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

Setting of metadata of referenced objects during saving is not possible #17

Open
muhrin opened this issue Nov 21, 2020 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@muhrin
Copy link
Owner

muhrin commented Nov 21, 2020

If you are saving object a which has a reference to object b, but b has not been saved yet, it is not possible to set metadata on b in the save_instance_state call of a because mincepy will try finding b's obj_id and fail.

This is quite restrictive and it would be useful to be able to set the metadata of referenced objects in certain scenarios.

One possible way to implement it would be to have the transaction keep track of metadata operations using a weakref dict (in addition to the obj_id tracking). This way if, by the end of the trasnaction, the object does have an object id (because save is called on it somewhere during the transaction), then the metadata will also be saved. The one downside with this is that, if the object is not saved during the transaction then the metadata will be silently lost.

@muhrin muhrin added the bug Something isn't working label Nov 21, 2020
@muhrin muhrin self-assigned this Nov 21, 2020
muhrin added a commit that referenced this issue Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant