Skip to content

Commit

Permalink
Panic on missing join clause
Browse files Browse the repository at this point in the history
Fix #43
  • Loading branch information
gwenn committed Mar 16, 2024
1 parent 37171cd commit 0170578
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lexer/sql/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ fn natural_join_on() {
);
}

#[test]
fn missing_join_clause() {
expect_parser_err_msg(
b"SELECT a FROM tt ON b",
"a JOIN clause is required before ON",
);
}

#[test]
fn unknown_table_option() {
expect_parser_err_msg(b"CREATE TABLE t(x)o", "unknown table option: o");
Expand Down
4 changes: 3 additions & 1 deletion src/parser/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,9 @@ impl FromClause {
self.joins = Some(vec![jst]);
}
} else {
debug_assert!(jc.is_none());
if jc.is_some() {
return Err(custom_err!("a JOIN clause is required before ON"));
}
debug_assert!(self.select.is_none());
debug_assert!(self.joins.is_none());
self.select = Some(Box::new(table));
Expand Down

0 comments on commit 0170578

Please sign in to comment.