Rahul_Dabhi
Rahul_Dabhi

Reputation: 730

dynamo db error Invalid ProjectionExpression: An expression attribute name used in the document path is not defined; attribute name: #P

I am trying to get and delete the data from dynamo db using some 2 primary key column, In which one is reserved keyword timestamp.

When I get data using one of the primary key then it is working fine, But when I trying to delete using two primary key field in projection expression it giving me an error like :

ValidationException: Invalid ProjectionExpression: An expression attribute name used in the document path is not defined; attribute name: #P

And this is my params object

{ TableName: 'Log', ProjectionExpression: 'username, #P', ExpressionAttributeNames: { '#P': 'timestamp' }, ExpressionAttributeValues: null }

username and timestamp are primary key columns.

This thing is not working in only this table. In some others table I have same situation but it will not throwing me this error. Only in this case I am getting the error.

Upvotes: 1

Views: 2968

Answers (1)

Alexander Patrikalakis
Alexander Patrikalakis

Reputation: 5195

The DeleteItem API does not allow you to specify a ProjectionExpression. You can get the entire pre-deletion image of the item by selecting ReturnValues = ALL_OLD.

Upvotes: 0

Related Questions