Skip to content

Commit e782bf5

Browse files
committed
Add error tests
1 parent bb0dad8 commit e782bf5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/parser/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4592,7 +4592,8 @@ impl<'a> Parser<'a> {
45924592
let option = match self.parse_one_of_keywords(&[Keyword::CASCADE, Keyword::RESTRICT]) {
45934593
Some(Keyword::CASCADE) => Some(ReferentialAction::Cascade),
45944594
Some(Keyword::RESTRICT) => Some(ReferentialAction::Restrict),
4595-
_ => None,
4595+
Some(_) => unreachable!(), // parse_one_of_keywords does not return other keywords
4596+
None => None,
45964597
};
45974598
Ok(Statement::DropProcedure {
45984599
if_exists,

tests/sqlparser_postgres.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,6 +3717,18 @@ fn parse_drop_procedure() {
37173717
option: None
37183718
}
37193719
);
3720+
3721+
let res = pg().parse_sql_statements("DROP PROCEDURE testproc DROP");
3722+
assert_eq!(
3723+
ParserError::ParserError("Expected: end of statement, found: DROP".to_string()),
3724+
res.unwrap_err()
3725+
);
3726+
3727+
let res = pg().parse_sql_statements("DROP PROCEDURE testproc SET NULL");
3728+
assert_eq!(
3729+
ParserError::ParserError("Expected: end of statement, found: SET".to_string()),
3730+
res.unwrap_err()
3731+
);
37203732
}
37213733

37223734
#[test]

0 commit comments

Comments
 (0)