Support ReturnValuesOnConditionCheckFailure for non-transactional operation#1263
Open
spendo wants to merge 1 commit intopynamodb:masterfrom
Open
Support ReturnValuesOnConditionCheckFailure for non-transactional operation#1263spendo wants to merge 1 commit intopynamodb:masterfrom
spendo wants to merge 1 commit intopynamodb:masterfrom
Conversation
Author
|
cc @ikonst |
ryancausey
reviewed
Sep 15, 2025
Contributor
ryancausey
left a comment
There was a problem hiding this comment.
@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]: |
Contributor
There was a problem hiding this comment.
This could be typed as:
Suggested change
| 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]]: |
Contributor
There was a problem hiding this comment.
This could be typed as:
Suggested change
| 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: |
Contributor
There was a problem hiding this comment.
This could be simplified to:
Suggested change
| 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, |
Contributor
There was a problem hiding this comment.
This could be typed as:
Suggested change
| return_values_on_condition_failure: Optional[str] = None, | |
| return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related: #1219