From 18e179e578c02c0df94c7b18b3ed71644ca5612d Mon Sep 17 00:00:00 2001 From: Dmitry Kolesnikov Date: Sat, 21 Dec 2024 15:44:58 +0200 Subject: [PATCH] fix Invalid ConditionExpression error --- service/ddb/constraint.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service/ddb/constraint.go b/service/ddb/constraint.go index 062e17c..59d5f7b 100644 --- a/service/ddb/constraint.go +++ b/service/ddb/constraint.go @@ -396,7 +396,9 @@ func maybeConditionExpression[T dynamo.Thing]( } } - *conditionExpression = aws.String(strings.Join(seq, " and ")) + if len(seq) > 0 { + *conditionExpression = aws.String(strings.Join(seq, " and ")) + } // Unfortunately empty maps are not accepted by DynamoDB if len(expressionAttributeNames) == 0 { @@ -429,7 +431,9 @@ func maybeUpdateConditionExpression[T dynamo.Thing]( } } - *conditionExpression = aws.String(strings.Join(seq, " and ")) + if len(seq) > 0 { + *conditionExpression = aws.String(strings.Join(seq, " and ")) + } // Unfortunately empty maps are not accepted by DynamoDB if len(expressionAttributeNames) == 0 {