You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm guessing somewhere the nested dict is being saved as a reference, not as a copy. I've confirmed it's not the query cache by setting it to zero.
This doesn't happen with normal JSON storage.
The text was updated successfully, but these errors were encountered:
helgridly
changed the title
MemoryStorage overwrites nested dicts on source objects
MemoryStorage keeps references to nested dicts
Jan 11, 2024
helgridly
changed the title
MemoryStorage keeps references to nested dicts
bug: MemoryStorage incorrectly keeps references to nested dicts
Jan 11, 2024
Hey @helgridly, you're absolutely right that TinyDB's MemoryStorage stores a reference, not a copy of the data that you insert. The correct solution to this would be to always create a deep copy of all data that is inserted to the database, but I'm somewhat conflicted as it also technically is a performance penalty for every write operation. Would it help to describe this behavior in the documentation, or do you think should be fixed on a deeper level?
obj
with a nested dictobj
's nested dictSee below:
I'm guessing somewhere the nested dict is being saved as a reference, not as a copy. I've confirmed it's not the query cache by setting it to zero.
This doesn't happen with normal JSON storage.
The text was updated successfully, but these errors were encountered: