Only raise EmptyKeyAttributeException when the value node is empty (#4014)
This fixes a bug where all updates to keys (including GSIs) would raise EmptyKeyAttributeException, even when the new value was not an empty string.
This commit is contained in:
parent
7f0475fc18
commit
67ae84e2c4
2 changed files with 28 additions and 1 deletions
|
|
@ -19,6 +19,29 @@ from moto.dynamodb2.parsing.expressions import UpdateExpressionParser
|
|||
from moto.dynamodb2.parsing.validators import UpdateExpressionValidator
|
||||
|
||||
|
||||
def test_valid_update_expression(table):
|
||||
update_expression = "set forum_name=:NewName, forum_type=:NewType"
|
||||
update_expression_values = {
|
||||
":NewName": {"S": "AmazingForum"},
|
||||
":NewType": {"S": "BASIC"},
|
||||
}
|
||||
update_expression_ast = UpdateExpressionParser.make(update_expression)
|
||||
item = Item(
|
||||
hash_key=DynamoType({"S": "forum_name"}),
|
||||
hash_key_type="TYPE",
|
||||
range_key=DynamoType({"S": "forum_type"}),
|
||||
range_key_type="TYPE",
|
||||
attrs={"forum_name": {"S": "hello"}},
|
||||
)
|
||||
UpdateExpressionValidator(
|
||||
update_expression_ast,
|
||||
expression_attribute_names=None,
|
||||
expression_attribute_values=update_expression_values,
|
||||
item=item,
|
||||
table=table,
|
||||
).validate()
|
||||
|
||||
|
||||
def test_validation_of_empty_string_key_val(table):
|
||||
with pytest.raises(EmptyKeyAttributeException):
|
||||
update_expression = "set forum_name=:NewName"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue