DynamoDB UpdateItem 失败
DynamoDB UpdateItem failed
我正在使用 DynamoDB Go SDK 进行 CRUD 操作。我验证了 PutItem
和 GetItem
调用工作正常。但是,当我使用 UpdateItem
更新某些属性时,它失败了。我将其缩小到特定于以纪元格式存储当前时间戳的属性。
updateItem := &dynamodb.UpdateItemInput{
TableName:aws.String(tableName),
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":r": {
S:aws.String("Renamed"),
},
":rp": {
S: aws.String("RenamingParty"),
},
":rr": {
S: aws.String("RenameReason"),
},
"rt": {
N: aws.String(strconv.FormatInt(time.Now().Unix(), 10)),
},
},
Key: map[string]*dynamodb.AttributeValue{
"pKey": {
S: aws.String(pKey),
},
"rKey": {
S:aws.String(rKey),
},
},
ReturnValues:aws.String("ALL_NEW"),
UpdateExpression:aws.String("set RenameStatus = :r, RenamingParty = :rp, RenameReason = :rr RenameTime = :rt"),
}
_, err := svc.UpdateItem(updateItem)
返回错误:
failed to update item: %v ValidationException: ExpressionAttributeValues contains invalid key: Syntax error; key: "rt"
status code: 400, request id:
您的属性 rt
似乎缺少 :
-> :rt
:)
我正在使用 DynamoDB Go SDK 进行 CRUD 操作。我验证了 PutItem
和 GetItem
调用工作正常。但是,当我使用 UpdateItem
更新某些属性时,它失败了。我将其缩小到特定于以纪元格式存储当前时间戳的属性。
updateItem := &dynamodb.UpdateItemInput{
TableName:aws.String(tableName),
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":r": {
S:aws.String("Renamed"),
},
":rp": {
S: aws.String("RenamingParty"),
},
":rr": {
S: aws.String("RenameReason"),
},
"rt": {
N: aws.String(strconv.FormatInt(time.Now().Unix(), 10)),
},
},
Key: map[string]*dynamodb.AttributeValue{
"pKey": {
S: aws.String(pKey),
},
"rKey": {
S:aws.String(rKey),
},
},
ReturnValues:aws.String("ALL_NEW"),
UpdateExpression:aws.String("set RenameStatus = :r, RenamingParty = :rp, RenameReason = :rr RenameTime = :rt"),
}
_, err := svc.UpdateItem(updateItem)
返回错误:
failed to update item: %v ValidationException: ExpressionAttributeValues contains invalid key: Syntax error; key: "rt" status code: 400, request id:
您的属性 rt
似乎缺少 :
-> :rt
:)