Skip to content

Commit

Permalink
rename to raw_item
Browse files Browse the repository at this point in the history
  • Loading branch information
knap1930 committed Feb 10, 2024
1 parent 7f757fb commit 0a423dc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/transaction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Now, say you make another attempt to debit one of the accounts when they don't h
assert e.cause_response_code == 'TransactionCanceledException'
# the first 'update' was a reason for the cancellation
assert e.cancellation_reasons[0].code == 'ConditionalCheckFailed'
# when return_values=ALL_OLD, the old values can be accessed from the item property
assert BankStatement.from_dynamodb_dict(e.cancellation_reasons[0].item) == user1_statement
# when return_values=ALL_OLD, the old values can be accessed from the raw_item property
assert BankStatement.from_dynamodb_dict(e.cancellation_reasons[0].raw_item) == user1_statement
# the second 'update' wasn't a reason, but was cancelled too
assert e.cancellation_reasons[1] is None
Expand Down
2 changes: 1 addition & 1 deletion pynamodb/connection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _make_api_call(self, operation_name: str, operation_kwargs: Dict) -> Dict:
CancellationReason(
code=d['Code'],
message=d.get('Message'),
item=cast(Optional[Dict[str, Dict[str, Any]]], d.get('Item')),
raw_item=cast(Optional[Dict[str, Dict[str, Any]]], d.get('Item')),
) if d['Code'] != 'None' else None
)
for d in cancellation_reasons
Expand Down
2 changes: 1 addition & 1 deletion pynamodb/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class CancellationReason:
"""
code: str
message: Optional[str] = None
item: Optional[Dict[str, Dict[str, Any]]] = None
raw_item: Optional[Dict[str, Dict[str, Any]]] = None


class TransactWriteError(PynamoDBException):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_transaction_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_transact_write__error__transaction_cancelled__condition_check_failure__
assert exc_info.value.cause_response_code == TRANSACTION_CANCELLED
assert 'ConditionalCheckFailed' in exc_info.value.cause_response_message
assert exc_info.value.cancellation_reasons == [
CancellationReason(code='ConditionalCheckFailed', message='The conditional request failed', item=User(1).to_dynamodb_dict()),
CancellationReason(code='ConditionalCheckFailed', message='The conditional request failed', raw_item=User(1).to_dynamodb_dict()),
]
assert isinstance(exc_info.value.cause, botocore.exceptions.ClientError)
assert User.Meta.table_name in exc_info.value.cause.MSG_TEMPLATE
Expand Down

0 comments on commit 0a423dc

Please sign in to comment.