summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/mutable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-06-24 10:31:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-06-24 10:31:46 -0400
commit271c38fd15b94d8acd0e6f054c8001b22535844e (patch)
tree4209cd2330fe97f32e488e85a4f45b83cc057e28 /lib/sqlalchemy/ext/mutable.py
parent6f3a7988599b73677198af20f680fefde723c160 (diff)
downloadsqlalchemy-271c38fd15b94d8acd0e6f054c8001b22535844e.tar.gz
add fallback for old mutable format
Fixed regression caused by :ticket:`8133` where the pickle format for mutable attributes was changed, without a fallback to recognize the old format, causing in-place upgrades of SQLAlchemy to no longer be able to read pickled data from previous versions. A check plus a fallback for the old format is now in place. Fixes: #8133 Change-Id: I9029729b4bc56c8b3145797869229eeff48a3b3b
Diffstat (limited to 'lib/sqlalchemy/ext/mutable.py')
-rw-r--r--lib/sqlalchemy/ext/mutable.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py
index 1ae5aee8b..06c46a9df 100644
--- a/lib/sqlalchemy/ext/mutable.py
+++ b/lib/sqlalchemy/ext/mutable.py
@@ -502,8 +502,14 @@ class MutableBase:
def unpickle(state, state_dict):
if "ext.mutable.values" in state_dict:
- for val in state_dict["ext.mutable.values"][key]:
- val._parents[state] = key
+ collection = state_dict["ext.mutable.values"]
+ if isinstance(collection, list):
+ # legacy format
+ for val in collection:
+ val._parents[state] = key
+ else:
+ for val in state_dict["ext.mutable.values"][key]:
+ val._parents[state] = key
event.listen(parent_cls, "load", load, raw=True, propagate=True)
event.listen(