From 71e86ab41737b0659486f7d95c053370a57f388e Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 5 Oct 2019 11:33:34 +0100 Subject: [PATCH] #1834 - Bugfix when removing item in double nested maps --- moto/dynamodb2/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 3f525f3ad..c06014488 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -197,15 +197,18 @@ class Item(BaseModel): # Hack but it'll do, traverses into a dict last_val_type = list(last_val.keys()) if last_val_type and last_val_type[0] == 'M': - last_val = last_val['M'] + last_val = last_val['M'] if key_part not in last_val: last_val[key_part] = {'M': {}} last_val = last_val[key_part] - last_val.pop(key_parts[-1], None) - self.attrs.pop(value, None) + last_val_type = list(last_val.keys()) + if last_val_type and last_val_type[0] == 'M': + last_val['M'].pop(key_parts[-1], None) + else: + last_val.pop(key_parts[-1], None) elif action == 'SET': key, value = value.split("=", 1) key = key.strip()