Skip to content

Commit

Permalink
fix parser error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Mar 13, 2024
1 parent 3b46378 commit fb219cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 12 additions & 2 deletions vendored/sqlite3-parser/src/parser/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,11 @@ impl FromClause {
}
}

pub(crate) fn push(&mut self, table: SelectTable, jc: Option<JoinConstraint>) {
pub(crate) fn push(
&mut self,
table: SelectTable,
jc: Option<JoinConstraint>,
) -> Result<(), ParserError> {
let op = self.op.take();
if let Some(op) = op {
let jst = JoinedSelectTable {
Expand All @@ -1463,11 +1467,17 @@ impl FromClause {
self.joins = Some(vec![jst]);
}
} else {
debug_assert!(jc.is_none());
if jc.is_some() {
return Err(ParserError::Custom(
"a JOIN clause is required before ON".to_string(),
));
}
debug_assert!(self.select.is_none());
debug_assert!(self.joins.is_none());
self.select = Some(Box::new(table));
}

Ok(())
}

pub(crate) fn push_op(&mut self, op: JoinOperator) {
Expand Down
8 changes: 4 additions & 4 deletions vendored/sqlite3-parser/src/parser/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -622,26 +622,26 @@ seltablist(A) ::= stl_prefix(A) fullname(Y) as(Z) indexed_opt(I)
on_using(N). {
let st = SelectTable::Table(Y, Z, I);
let jc = N;
A.push(st, jc);
A.push(st, jc)?;
}
seltablist(A) ::= stl_prefix(A) fullname(Y) LP exprlist(E) RP as(Z)
on_using(N). {
let st = SelectTable::TableCall(Y, E, Z);
let jc = N;
A.push(st, jc);
A.push(st, jc)?;
}
%ifndef SQLITE_OMIT_SUBQUERY
seltablist(A) ::= stl_prefix(A) LP select(S) RP
as(Z) on_using(N). {
let st = SelectTable::Select(S, Z);
let jc = N;
A.push(st, jc);
A.push(st, jc)?;
}
seltablist(A) ::= stl_prefix(A) LP seltablist(F) RP
as(Z) on_using(N). {
let st = SelectTable::Sub(F, Z);
let jc = N;
A.push(st, jc);
A.push(st, jc)?;
}
%endif SQLITE_OMIT_SUBQUERY

Expand Down

0 comments on commit fb219cd

Please sign in to comment.