-
Notifications
You must be signed in to change notification settings - Fork 434
Support ReturnValuesOnConditionCheckFailure for non-transactional operation #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Support ReturnValuesOnConditionCheckFailure for non-transactional operation #1263
Conversation
cc @ikonst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ikonst I just discovered this as I was looking for how to do this with PynamoDB. Is this something that can be added to the library in its current form?
return data | ||
|
||
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True) -> Dict[str, Any]: | ||
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Dict[str, Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be typed as:
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Dict[str, Any]: | |
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None) -> Dict[str, Any]: |
return schema | ||
|
||
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True) -> Tuple[Iterable[Any], Dict[str, Any]]: | ||
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Tuple[Iterable[Any], Dict[str, Any]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be typed as:
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Tuple[Iterable[Any], Dict[str, Any]]: | |
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None) -> Tuple[Iterable[Any], Dict[str, Any]]: |
condition &= version_condition | ||
kwargs['attributes'] = attribute_values | ||
kwargs['condition'] = condition | ||
if return_values_on_condition_failure and return_values_on_condition_failure is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified to:
if return_values_on_condition_failure and return_values_on_condition_failure is not None: | |
if return_values_on_condition_failure: |
return_values: Optional[str] = None, | ||
return_consumed_capacity: Optional[str] = None, | ||
return_item_collection_metrics: Optional[str] = None, | ||
return_values_on_condition_failure: Optional[str] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be typed as:
return_values_on_condition_failure: Optional[str] = None, | |
return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None, |
related: #1219