Parse a FROM clause
(mut tables: Vec<TableWithJoins>)
| 27 | |
| 28 | /// Parse a FROM clause |
| 29 | fn parse_from(mut tables: Vec<TableWithJoins>) -> SqlParseResult<SqlFrom> { |
| 30 | if tables.is_empty() { |
| 31 | return Err(SqlRequired::From.into()); |
| 32 | } |
| 33 | if tables.len() > 1 { |
| 34 | return Err(SqlUnsupported::ImplicitJoins.into()); |
| 35 | } |
| 36 | let TableWithJoins { relation, joins } = tables.swap_remove(0); |
| 37 | let (name, alias) = Self::parse_relvar(relation)?; |
| 38 | if joins.is_empty() { |
| 39 | return Ok(SqlFrom::Expr(name, alias)); |
| 40 | } |
| 41 | Ok(SqlFrom::Join(name, alias, Self::parse_joins(joins)?)) |
| 42 | } |
| 43 | |
| 44 | /// Parse a sequence of JOIN clauses |
| 45 | fn parse_joins(joins: Vec<Join>) -> SqlParseResult<Vec<SqlJoin>> { |