Skip to content

Commit 8a0337d

Browse files
test: reject unmatched parentheses in SET value
Adds the unit tests suggested on #158: an opening paren with no matching close, and a stray closing paren, must each raise ValidationException rather than panic or be silently accepted.
1 parent da4a15b commit 8a0337d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

crates/core/src/expression/update_parser.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,4 +547,25 @@ mod tests {
547547
let actions = parse("SET c = (c - :v)").unwrap();
548548
assert!(matches!(&actions[0], UpdateAction::Set { .. }));
549549
}
550+
551+
#[test]
552+
fn unmatched_paren_rejected() {
553+
// Opening paren with no matching close must be a ValidationException,
554+
// not a panic or a silently-accepted expression.
555+
let err = parse("SET c = (c - :v").unwrap_err();
556+
assert!(
557+
matches!(&err, DynamoDbError::ValidationException(msg) if msg.contains("closing")),
558+
"Expected unmatched-paren error, got: {err:?}"
559+
);
560+
}
561+
562+
#[test]
563+
fn unmatched_close_paren_rejected() {
564+
// A stray closing paren with no matching open must also be rejected.
565+
let err = parse("SET c = c - :v)").unwrap_err();
566+
assert!(
567+
matches!(&err, DynamoDbError::ValidationException(_)),
568+
"Expected validation error for stray ')', got: {err:?}"
569+
);
570+
}
550571
}

0 commit comments

Comments
 (0)