Reputation: 6512
I get the following error when I try to do a conditional update:
Invalid ConditionExpression: Syntax error; token: "-", near: "PageRouteee1181aa-8035"
I have the following class:
public class RestaurantPageRouteItem
{
[DynamoDBHashKey]
public string PageRoute { get; set; }
public string RestaurantId { get; set; }
}
And Im creating the following expression:
new Expression
{
ExpressionStatement = $"attribute_not_exists({item.PageRoute}) OR {item.RestaurantId} = :restaurantid",
ExpressionAttributeValues =
{
[":restaurantid"] = item.RestaurantId
}
}
Upvotes: 1
Views: 682
Reputation: 6512
Managed to come up with the following:
new Expression {
ExpressionStatement =
"(attribute_not_exists(#ID) OR :id = #ID) OR " +
"(attribute_not_exists(PageRoute))",
ExpressionAttributeValues = {
[":id"] = item.RestaurantId
},
ExpressionAttributeNames = {
["#ID"] = "RestaurantId"
}
}
Upvotes: 1