Conditional update trouble
Using the update_item() method in the Model class in pynamodb.models is a giving me trouble. If I don't pass an action argument, it defaults to None and then when it hits action.upper() in this part of update_item()
kwargs[pythonic(ATTR_UPDATES)] = {
attribute: {
ACTION: action.upper(),
VALUE: {
ATTR_TYPE_MAP[attribute_cls.attr_type]: value
}
}
}
the method fails. Shouldn't the action argument be required, if it defaults to None and then crashes because it is the default value?
I think this fix caused a big issue to update item. The range key is missing in update_item function.
args, _ = self._get_save_args(null_check=False) kwargs = {}
See the range key is not in kwargs in this case.
kwargs = {} if len(expected_values): kwargs.update(expected=self._build_expected_values(expected_values, UPDATE_FILTER_OPERATOR_MAP)) kwargs[pythonic(ATTR_UPDATES)] = { attribute: { ACTION: action.upper() if action else None, VALUE: { ATTR_TYPE_MAP[attribute_cls.attr_type]: value } } } kwargs[pythonic(RETURN_VALUES)] = ALL_NEW kwargs.update(conditional_operator=conditional_operator) data = self._get_connection().update_item( _args, *_kwargs )