-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Example:
for (const partialExpression of partialExpressions) {
const partialExpressionOrderedTokens = (partialExpression || '').replace(/^(DELETE|ADD|SET|REMOVE)\s+/i, '')
.trim().split(',').filter(token => token).map(token => token.trim());
const isValidKey = operand => operand.match(/^#\w+(\.#\w)*$/);
const isValidOperand = operand => operand.match(/^:\w+$/) || operand.match(/^(#\w+(\.#\w)*|:\w+)[-+](#\w+(\.#\w)*|:\w+)$/);
const arrayIterator = partialExpressionOrderedTokens[Symbol.iterator]();
let result;
while ((result = arrayIterator.next()) && !result.done) {
const key = arrayIterator.next().value;
const equalSign = arrayIterator.next().value;
const operand = arrayIterator.next().value;
if (!isValidKey(key) || equalSign !== '=' || !isValidOperand(operand)) {
logger({ code: 'InvalidExpression', expression });
throw new DynamoDbError({
title: 'Invalid Expression: the expression does not match what DynamoDB expects: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html', expression,
tokens: [key, equalSign, operand]
}, 'InvalidExpression');
}
// parseExpressionRecursive(token, orderedTokens);
}
}
Metadata
Metadata
Assignees
Labels
No labels