add attrs to debug
This commit is contained in:
@@ -500,7 +500,11 @@ class DynamoDBPersistenceLayer:
|
||||
|
||||
- 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:
|
||||
attrs['ExpressionAttributeNames'] = expr_attr_name
|
||||
@@ -518,13 +522,10 @@ class DynamoDBPersistenceLayer:
|
||||
attrs['Limit'] = limit
|
||||
|
||||
try:
|
||||
response = self.dynamodb_client.query(
|
||||
TableName=self.table_name,
|
||||
KeyConditionExpression=key_cond_expr,
|
||||
**attrs,
|
||||
)
|
||||
response = self.dynamodb_client.query(**attrs)
|
||||
except ClientError as err:
|
||||
logger.exception(err)
|
||||
logger.debug(attrs)
|
||||
raise
|
||||
else:
|
||||
return dict(
|
||||
@@ -536,32 +537,34 @@ class DynamoDBPersistenceLayer:
|
||||
"""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.
|
||||
"""
|
||||
attrs = {
|
||||
'TableName': self.table_name,
|
||||
'Key': serialize(key),
|
||||
}
|
||||
|
||||
try:
|
||||
response = self.dynamodb_client.get_item(
|
||||
TableName=self.table_name,
|
||||
Key=serialize(key),
|
||||
)
|
||||
response = self.dynamodb_client.get_item(**attrs)
|
||||
except ClientError as err:
|
||||
logger.exception(err)
|
||||
logger.debug(attrs)
|
||||
raise
|
||||
else:
|
||||
return deserialize(response.get('Item', {}))
|
||||
|
||||
def put_item(self, item: dict, *, cond_expr: str | None = None) -> bool:
|
||||
attrs = {}
|
||||
attrs = {
|
||||
'TableName': self.table_name,
|
||||
'Item': serialize(item),
|
||||
}
|
||||
|
||||
if cond_expr:
|
||||
attrs['ConditionExpression'] = cond_expr
|
||||
|
||||
try:
|
||||
self.dynamodb_client.put_item(
|
||||
TableName=self.table_name,
|
||||
Item=serialize(item),
|
||||
**attrs,
|
||||
)
|
||||
self.dynamodb_client.put_item(**attrs)
|
||||
except ClientError as err:
|
||||
logger.exception(err)
|
||||
logger.debug(attrs)
|
||||
raise
|
||||
else:
|
||||
return True
|
||||
@@ -575,7 +578,11 @@ class DynamoDBPersistenceLayer:
|
||||
expr_attr_names: dict | None = None,
|
||||
expr_attr_values: dict | None = None,
|
||||
) -> bool:
|
||||
attrs: dict = {}
|
||||
attrs: dict = {
|
||||
'TableName': self.table_name,
|
||||
'Key': serialize(key),
|
||||
'UpdateExpression': update_expr,
|
||||
}
|
||||
|
||||
if cond_expr:
|
||||
attrs['ConditionExpression'] = cond_expr
|
||||
@@ -587,14 +594,10 @@ class DynamoDBPersistenceLayer:
|
||||
attrs['ExpressionAttributeValues'] = serialize(expr_attr_values)
|
||||
|
||||
try:
|
||||
self.dynamodb_client.update_item(
|
||||
TableName=self.table_name,
|
||||
Key=serialize(key),
|
||||
UpdateExpression=update_expr,
|
||||
**attrs,
|
||||
)
|
||||
self.dynamodb_client.update_item(**attrs)
|
||||
except ClientError as err:
|
||||
logger.exception(err)
|
||||
logger.debug(attrs)
|
||||
raise
|
||||
else:
|
||||
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
|
||||
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:
|
||||
attrs['ConditionExpression'] = cond_expr
|
||||
@@ -622,11 +628,10 @@ class DynamoDBPersistenceLayer:
|
||||
attrs['ExpressionAttributeValues'] = serialize(expr_attr_values)
|
||||
|
||||
try:
|
||||
self.dynamodb_client.delete_item(
|
||||
TableName=self.table_name, Key=serialize(key), **attrs
|
||||
)
|
||||
self.dynamodb_client.delete_item(**attrs)
|
||||
except ClientError as err:
|
||||
logger.exception(err)
|
||||
logger.debug(attrs)
|
||||
raise
|
||||
else:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user