generated from amazon-archives/__template_MIT-0
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 455
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What were you trying to accomplish?
Expected Behavior
I should be able to use DynamoDB reserved words as Item attributes. For example, ttl is a common DynamoDB Item Time to Live attribute name. A consumer should be able to specify reserved word attribute names for any of the *_attr values when configuring DynamoDBPersistenceLayer.
Current Behavior
_put_record currently throws an exception b/c it uses Python string interpolation instead of ExpressionAttributeNames.
Possible Solution
Switch to ExpressionAttributeNames, e.g.
            self.table.put_item(
                Item=item,
                ConditionExpression='attribute_not_exists(#key) OR #now < :now',
                ExpressionAttributeNames={"#key": self.key_attr, "#now": self.expiry_attr},
                ExpressionAttributeValues={":now": int(now.timestamp())},
            )
Steps to Reproduce (for bugs)
- Create a DynamoDB table with a Time to Live attribute called ttl.
- Configure a DynamoDBPersistenceLayerwithexpiry_attr='ttl'
- Run
Environment
- Powertools version used: 1.20.2
- Packaging format (Layers, PyPi): PyPi
- AWS Lambda function runtime: Python 3.8
- Debugging logs
# paste logs hereMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working