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
After second deserialization for example it doubles counts like for example there were 10 items Item.all.count #=> 10 and after deserialization it's 20. And every item is with the same ids.
Why it can be?
P.S. it seems there is no dup method like in activerecord to create shallow copy of object. Is it needed in library?
The text was updated successfully, but these errors were encountered:
Ok, I have a repro case. Let me look into this. I assume the desired behavior is that the contents of the in-memory store, dirty or not, is discarded in favor of the data being deserialized. Would that be your understanding?
I'd like to understand the use case for this a bit better. The typical usage is to deserialize on launch and then serialize on change. So the second deserialization would typically not happen unless the app were evicted from memory or crashed. In those cases, the data store would begin empty and no dups would appear.
Is there a different use case where multiple deserializations are necessary?
First count is 0
Count after serialize is 1
Item id is 2
Item id is 2
Item id is 2
Item id is 2
Item id is 2
Count after two deserialization is 5
[FAILED - 5.==(1) failed]
The same behaviour can be replicated in repl.
Desired behaviour is so after deserialization I can't have duplicate not unique items.
Maybe it is not a bug. Before that i make this code https://github.com/onemanstartup/motion_model_possible_bug/blob/master/app/item.rb#L7-L12
so attrs = self.attributes without dup caused problem of empty association, and trying debugging that i stumped with this deserialization in repl. Now it seems it is not right to call multiple times deserialization, but behaviour is not clear and possible can lead to bugs.
After second deserialization for example it doubles counts like for example there were 10 items
Item.all.count #=> 10
and after deserialization it's 20. And every item is with the same ids.Why it can be?
P.S. it seems there is no dup method like in activerecord to create shallow copy of object. Is it needed in library?
The text was updated successfully, but these errors were encountered: