4ossiblellc / dynamodb-update-expression

A small library providing the solution to return the DynamoDB update expression.
MIT License
25 stars 15 forks source link

Special char '-' not allowed in ExpressionAttributeNames or Values #17

Closed rchepya1 closed 5 years ago

rchepya1 commented 5 years ago

Dynamodb update doesn't allow special character '-' in ExpressionAttributeNames and ExpressionAttributeValues. But it could be present in the dynamoDb. For example UUID can be a key in an object.

{ "xyz": { "fd324157-7aaa-4ef4-baa5-47952b9e189b": { "abc": "abcValue", "pqr": { "pqrKey": "pqrValue" } } } }

If something's updated in 'abc' - UpdateExpression is : "SET #xyz.#fd324157-7aaa-4ef4-baa5-47952b9e189b.#abc = :xyzfd324157-7aaa-4ef4-baa5-47952b9e189babc, ExpressionAttributeNames : #fd324157-7aaa-4ef4-baa5-47952b9e189b : "fd324157-7aaa-4ef4-baa5-47952b9e189b" ExpressionAttributeValues: :xyzfd324157-7aaa-4ef4-baa5-47952b9e189babc : "newValue"

The special char '-' is not allowed here. But is needed in ExpressionAttributeNames's value.

Error: ExpressionAttributeNames contains invalid key: Syntax error; key: "#fd324157-7aaa-4ef4-baa5-47952b9e189b"

rchepya1 commented 5 years ago

PR: https://github.com/4ossiblellc/dynamodb-update-expression/pull/18

This would replace the uuid containing '-' with uuid without the special char in the keys of UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues and doesn't replace in values. Values shouldn't be replaced since it maps to the dynamoDb's key/id

4ossiblellc commented 5 years ago

Closed this issue.