I'm attempting to update an item within a DynamoDB table using the C# low-level API as documented here
Here is my attempt at achieving this:
var response = DynamoClientProvider.Current.UpdateItem(new UpdateItemRequest
{
TableName = "MyTable",
Key = {{"TableId", new AttributeValue {S = "12345"}}},
ExpressionAttributeNames =
{
{"#T","Timestamp"},
{"#D","Data"}
{"#K","MyKey"}
},
ExpressionAttributeValues =
{
{":Timestamp", new AttributeValue("2016-2-3 00:00:00.000")},
{":Data", new AttributeValue("some data")}
{":MyKey", new AttributeValue("some other data")}
},
UpdateExpression = "SET #D = :Data, #T = :Timestamp, #K = :MyKey",
ConditionExpression = "attribute_not_exists (Data)",
ReturnValues = ReturnValue.ALL_OLD
});
This code works just fine, however there is an issue when MyKey is an empty string. When this is empty, I get the following error:
Amazon.DynamoDBv2.AmazonDynamoDBException: ExpressionAttributeValues contains invalid value: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes for key :MyKey
I have therefore attempted to therefore pass in a null AttributeValue in order to delete the attribute in this case by setting it to the following:
new AttributeValue{NULL = true}
However this instead will set the value to be the string literal of True