Skip to content

Commit

Permalink
Add error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jul 8, 2024
1 parent bb0dad8 commit e782bf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4592,7 +4592,8 @@ impl<'a> Parser<'a> {
let option = match self.parse_one_of_keywords(&[Keyword::CASCADE, Keyword::RESTRICT]) {
Some(Keyword::CASCADE) => Some(ReferentialAction::Cascade),
Some(Keyword::RESTRICT) => Some(ReferentialAction::Restrict),
_ => None,
Some(_) => unreachable!(), // parse_one_of_keywords does not return other keywords
None => None,
};
Ok(Statement::DropProcedure {
if_exists,
Expand Down
12 changes: 12 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,18 @@ fn parse_drop_procedure() {
option: None
}
);

let res = pg().parse_sql_statements("DROP PROCEDURE testproc DROP");
assert_eq!(
ParserError::ParserError("Expected: end of statement, found: DROP".to_string()),
res.unwrap_err()
);

let res = pg().parse_sql_statements("DROP PROCEDURE testproc SET NULL");
assert_eq!(
ParserError::ParserError("Expected: end of statement, found: SET".to_string()),
res.unwrap_err()
);
}

#[test]
Expand Down

0 comments on commit e782bf5

Please sign in to comment.