Reputation: 131
I need to update a row in Dynomodb while doing so need to include a new column which is already not there.
resp = table.update_item(
Key={
'Pkey': 'key1',
'Skey': 'skwy2'
},
UpdateExpression='ADD dateModified = :input2, SET IsActive = :input1',
ExpressionAttributeValues={
':input1': False,
':input2' : datetime.datetime.now(timezone.utc)
},
ReturnValues="UPDATED_NEW"
)
now I need to update IsActive field to false and insert new dateModified value to that .
getting error as Invalid UpdateExpression: Syntax error; token: "=", near: "dateModified = :input2"
Upvotes: 1
Views: 2237
Reputation: 15079
you can see in https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.ADD that for the ADD
operation you don't use =
so the correct expression should be ADD dateModified :input2 SET IsActive = :input1
Upvotes: 1