Merge pull request #71 from benesch/infix

Don't panic when NOT is not followed by an expected keyword
This commit is contained in:
Nickolay Ponomarev 2019-05-22 01:18:23 +03:00 committed by GitHub
commit 4f944dd4aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -441,7 +441,7 @@ impl Parser {
} else if self.parse_keyword("BETWEEN") {
self.parse_between(expr, negated)
} else {
panic!()
self.expected("IN or BETWEEN after NOT", self.peek_token())
}
}
// Can only happen if `get_precedence` got out of sync with this function

View file

@ -209,6 +209,15 @@ fn parse_not() {
//TODO: add assertions
}
#[test]
fn parse_invalid_infix_not() {
let res = parse_sql_statements("SELECT c FROM t WHERE c NOT (");
assert_eq!(
ParserError::ParserError("Expected IN or BETWEEN after NOT, found: (".to_string()),
res.unwrap_err(),
);
}
#[test]
fn parse_collate() {
let sql = "SELECT name COLLATE \"de_DE\" FROM customer";