add attrs to debug

This commit is contained in:
2025-05-22 15:58:39 -03:00
parent d4418ef94e
commit a51723f64f

View File

@@ -500,7 +500,11 @@ class DynamoDBPersistenceLayer:
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/client/query.html - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/client/query.html
""" """
attrs: dict = {'ScanIndexForward': index_forward} attrs: dict = {
'TableName': self.table_name,
'KeyConditionExpression': key_cond_expr,
'ScanIndexForward': index_forward,
}
if expr_attr_name: if expr_attr_name:
attrs['ExpressionAttributeNames'] = expr_attr_name attrs['ExpressionAttributeNames'] = expr_attr_name
@@ -518,13 +522,10 @@ class DynamoDBPersistenceLayer:
attrs['Limit'] = limit attrs['Limit'] = limit
try: try:
response = self.dynamodb_client.query( response = self.dynamodb_client.query(**attrs)
TableName=self.table_name,
KeyConditionExpression=key_cond_expr,
**attrs,
)
except ClientError as err: except ClientError as err:
logger.exception(err) logger.exception(err)
logger.debug(attrs)
raise raise
else: else:
return dict( return dict(
@@ -536,32 +537,34 @@ class DynamoDBPersistenceLayer:
"""The GetItem operation returns a set of attributes for the item with the given primary key. """The GetItem operation returns a set of attributes for the item with the given primary key.
If there is no matching item, GetItem does not return any data and there will be no Item element in the response. If there is no matching item, GetItem does not return any data and there will be no Item element in the response.
""" """
attrs = {
'TableName': self.table_name,
'Key': serialize(key),
}
try: try:
response = self.dynamodb_client.get_item( response = self.dynamodb_client.get_item(**attrs)
TableName=self.table_name,
Key=serialize(key),
)
except ClientError as err: except ClientError as err:
logger.exception(err) logger.exception(err)
logger.debug(attrs)
raise raise
else: else:
return deserialize(response.get('Item', {})) return deserialize(response.get('Item', {}))
def put_item(self, item: dict, *, cond_expr: str | None = None) -> bool: def put_item(self, item: dict, *, cond_expr: str | None = None) -> bool:
attrs = {} attrs = {
'TableName': self.table_name,
'Item': serialize(item),
}
if cond_expr: if cond_expr:
attrs['ConditionExpression'] = cond_expr attrs['ConditionExpression'] = cond_expr
try: try:
self.dynamodb_client.put_item( self.dynamodb_client.put_item(**attrs)
TableName=self.table_name,
Item=serialize(item),
**attrs,
)
except ClientError as err: except ClientError as err:
logger.exception(err) logger.exception(err)
logger.debug(attrs)
raise raise
else: else:
return True return True
@@ -575,7 +578,11 @@ class DynamoDBPersistenceLayer:
expr_attr_names: dict | None = None, expr_attr_names: dict | None = None,
expr_attr_values: dict | None = None, expr_attr_values: dict | None = None,
) -> bool: ) -> bool:
attrs: dict = {} attrs: dict = {
'TableName': self.table_name,
'Key': serialize(key),
'UpdateExpression': update_expr,
}
if cond_expr: if cond_expr:
attrs['ConditionExpression'] = cond_expr attrs['ConditionExpression'] = cond_expr
@@ -587,14 +594,10 @@ class DynamoDBPersistenceLayer:
attrs['ExpressionAttributeValues'] = serialize(expr_attr_values) attrs['ExpressionAttributeValues'] = serialize(expr_attr_values)
try: try:
self.dynamodb_client.update_item( self.dynamodb_client.update_item(**attrs)
TableName=self.table_name,
Key=serialize(key),
UpdateExpression=update_expr,
**attrs,
)
except ClientError as err: except ClientError as err:
logger.exception(err) logger.exception(err)
logger.debug(attrs)
raise raise
else: else:
return True return True
@@ -610,7 +613,10 @@ class DynamoDBPersistenceLayer:
"""Deletes a single item in a table by primary key. You can perform a conditional delete operation that deletes """Deletes a single item in a table by primary key. You can perform a conditional delete operation that deletes
the item if it exists, or if it has an expected attribute value. the item if it exists, or if it has an expected attribute value.
""" """
attrs: dict = {} attrs: dict = {
'TableName': self.table_name,
'Key': serialize(key),
}
if cond_expr: if cond_expr:
attrs['ConditionExpression'] = cond_expr attrs['ConditionExpression'] = cond_expr
@@ -622,11 +628,10 @@ class DynamoDBPersistenceLayer:
attrs['ExpressionAttributeValues'] = serialize(expr_attr_values) attrs['ExpressionAttributeValues'] = serialize(expr_attr_values)
try: try:
self.dynamodb_client.delete_item( self.dynamodb_client.delete_item(**attrs)
TableName=self.table_name, Key=serialize(key), **attrs
)
except ClientError as err: except ClientError as err:
logger.exception(err) logger.exception(err)
logger.debug(attrs)
raise raise
else: else:
return True return True