File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,10 @@ pub enum TableFactor {
226
226
subquery : Box < SQLQuery > ,
227
227
alias : Option < TableAlias > ,
228
228
} ,
229
+ /// Represents a parenthesized join expression, such as
230
+ /// `(foo <JOIN> bar [ <JOIN> baz ... ])`.
231
+ /// The inner `TableWithJoins` can have no joins only if its
232
+ /// `relation` is itself a `TableFactor::NestedJoin`.
229
233
NestedJoin ( Box < TableWithJoins > ) ,
230
234
}
231
235
Original file line number Diff line number Diff line change @@ -1712,14 +1712,14 @@ impl Parser {
1712
1712
self . index = index;
1713
1713
let table_and_joins = self . parse_table_and_joins ( ) ?;
1714
1714
match table_and_joins. relation {
1715
- TableFactor :: Table { .. } | TableFactor :: Derived { .. }
1716
- if table_and_joins. joins . is_empty ( ) =>
1717
- {
1718
- // The SQL spec prohibits derived tables and bare
1719
- // tables from appearing alone in parentheses.
1720
- self . expected ( "joined table" , self . peek_token ( ) ) ?
1715
+ TableFactor :: NestedJoin { .. } => ( ) ,
1716
+ _ => {
1717
+ if table_and_joins. joins . is_empty ( ) {
1718
+ // The SQL spec prohibits derived tables and bare
1719
+ // tables from appearing alone in parentheses.
1720
+ self . expected ( "joined table" , self . peek_token ( ) ) ?
1721
+ }
1721
1722
}
1722
- _ => ( ) ,
1723
1723
}
1724
1724
self . expect_token ( & Token :: RParen ) ?;
1725
1725
Ok ( TableFactor :: NestedJoin ( Box :: new ( table_and_joins) ) )
You can’t perform that action at this time.
0 commit comments