dynamodb: fix deleting last set element (w/attr name) (#3708)

* dynamodb: deleting last set element

* add user-facing test
This commit is contained in:
Ilya Konstantinov 2021-02-19 02:47:51 -05:00 committed by GitHub
commit 0912abe5f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 9 deletions

View file

@ -165,8 +165,18 @@ class DeleteExecutor(NodeExecutor):
# the last item in the set, we have to remove the attribute.
if not string_set_list:
element = self.get_element_to_action()
if isinstance(element, ExpressionAttributeName):
attribute_name = self.expression_attribute_names[
element.get_attribute_name_placeholder()
]
elif isinstance(element, ExpressionAttribute):
attribute_name = element.get_attribute_name()
else:
raise NotImplementedError(
"Moto does not support deleting {t} yet".format(t=type(element))
)
container = self.get_item_before_end_of_path(item)
container.pop(element.get_attribute_name())
del container[attribute_name]
class RemoveExecutor(NodeExecutor):