Skip to content

Commit 45c9aa1

Browse files
committed
Use self.expected() more
1 parent f18fbe5 commit 45c9aa1

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/sqlparser.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,7 @@ impl Parser {
890890
} else if self.parse_keyword("VIEW") {
891891
SQLObjectType::View
892892
} else {
893-
return parser_err!(format!(
894-
"Unexpected token after DROP: {:?}",
895-
self.peek_token()
896-
));
893+
return self.expected("TABLE or VIEW after DROP", self.peek_token());
897894
};
898895
let if_exists = self.parse_keywords(vec!["IF", "EXISTS"]);
899896
let mut names = vec![];
@@ -1015,10 +1012,7 @@ impl Parser {
10151012
self.expect_token(&Token::RParen)?;
10161013
ColumnOption::Check(expr)
10171014
} else {
1018-
return parser_err!(format!(
1019-
"Unexpected token in column definition: {:?}",
1020-
self.peek_token()
1021-
));
1015+
return self.expected("column option", self.peek_token());
10221016
};
10231017

10241018
Ok(ColumnOptionDef { name, option })
@@ -1216,7 +1210,7 @@ impl Parser {
12161210
pub fn parse_literal_string(&mut self) -> Result<String, ParserError> {
12171211
match self.next_token() {
12181212
Some(Token::SingleQuotedString(ref s)) => Ok(s.clone()),
1219-
other => parser_err!(format!("Expected literal string, found {:?}", other)),
1213+
other => self.expected("literal string", other),
12201214
}
12211215
}
12221216

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ fn parse_create_table() {
949949
assert!(res
950950
.unwrap_err()
951951
.to_string()
952-
.contains("Unexpected token in column definition"));
952+
.contains("Expected column option, found: GARBAGE"));
953953
}
954954

955955
#[test]

0 commit comments

Comments
 (0)