dynamodb-toolbox
dynamodb-toolbox copied to clipboard
Update using dashes
FooEntity.update({
dictionary: {
$set: {
'field-with-dash': 'bar',
},
},
})
This update will fail as the update method will generate an ExpressionAttributeName containing { '#field-with-dash': 'field-with-dash' } and the dynamoDb client will throw an error Invalid ExpressionAttributeName key as it doesn't handle the #field-with-dash key... 😞
Good catch. Looks like I'm just taking the attribute name and prefixing it with a #, but clearly that will cause issues. I should be able to switch it to an incrementing numerical index approach like I used for the projectionBuilder.
I'm also hitting the same issue, but due to using spaces not dashes. For example, when running this:
FooEntity.update({
dictionary: {
$set: {
'Hello World': 'bar',
},
},
})
...you get the error:
ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#dictionary_Hello World"
PR #96 looks like a good option, but it requires extra logic and I sorta feel like this use-case should work out of the box.
@jeremydaly Did you have an implementation in mind for this, or were you intending to merge #96? I'm happy to assist, either creating an alternative PR or updating the existing one?
Brilliant library BTW! Really enjoying using it.
I'm also facing the same issue when using uuid in set keys:
FooEntity.update({
dictionary: {
$set: {
'b2333002-55be-47b8-8fbb-2e1ed19a5ab3': 'bar',
},
},
})
I'm also facing the same issue. Any update on this ??