diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-06-15 01:46:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-06-15 01:46:39 +0000 |
commit | 1156c6f998ed2db0a34c31e34751a062bd0e6cdc (patch) | |
tree | e9b1a13df0e10b654d2ee341573d2ddc9df91b9d /lib/sqlalchemy/ext | |
parent | aa8ddf7d356e7ea8c100cca18bb49e3bd820ca31 (diff) | |
parent | 042bccd2e4d6fbfcdf70ede760b29f78771f4b22 (diff) | |
download | sqlalchemy-1156c6f998ed2db0a34c31e34751a062bd0e6cdc.tar.gz |
Merge "pickle mutable parents according to key" into main
Diffstat (limited to 'lib/sqlalchemy/ext')
-rw-r--r-- | lib/sqlalchemy/ext/mutable.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index ba7f9b0a4..1ae5aee8b 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -355,6 +355,7 @@ pickling process of the parent's object-relational state so that the :meth:`MutableBase._parents` collection is restored to all ``Point`` objects. """ +from collections import defaultdict import weakref from .. import event @@ -496,12 +497,12 @@ class MutableBase: val = state.dict.get(key, None) if val is not None: if "ext.mutable.values" not in state_dict: - state_dict["ext.mutable.values"] = [] - state_dict["ext.mutable.values"].append(val) + state_dict["ext.mutable.values"] = defaultdict(list) + state_dict["ext.mutable.values"][key].append(val) def unpickle(state, state_dict): if "ext.mutable.values" in state_dict: - for val in state_dict["ext.mutable.values"]: + for val in state_dict["ext.mutable.values"][key]: val._parents[state] = key event.listen(parent_cls, "load", load, raw=True, propagate=True) |