minidyn icon indicating copy to clipboard operation
minidyn copied to clipboard

[ConditionExpression] attribute_type not working

Open erudisch opened this issue 3 years ago • 1 comments

Hello

I want to insert item_a

{
  "AccountId": {
    "S": "123"
  }
}

with a conditional expression like this:

input := &dynamodb.PutItemInput{
    ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
	    ":v_sub": {
		    S: aws.String("S"),
	    },
    },
    ConditionExpression: aws.String("attribute_type(AccountId, :v_sub)"),
    Item:      av,
    TableName: &p.tableName,
}

av is the marshalled item_a

but unfortunately i get this error: ConditionalCheckFailedException: conditional request failed

According to the readme, attribute_type is supported.

i used these two docs as a reference: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html

kind regards erik

erudisch avatar Nov 25 '22 02:11 erudisch

Opps, sorry for the late response: the ConditionExpressions evaluates the already stored item, because the are used to avoid overrides in the PutItem operations.

kuadrosx avatar Nov 06 '23 21:11 kuadrosx