Parse a single JOIN clause
(join: Join)
| 48 | |
| 49 | /// Parse a single JOIN clause |
| 50 | fn parse_join(join: Join) -> SqlParseResult<SqlJoin> { |
| 51 | let (var, alias) = Self::parse_relvar(join.relation)?; |
| 52 | match join.join_operator { |
| 53 | JoinOperator::CrossJoin => Ok(SqlJoin { var, alias, on: None }), |
| 54 | JoinOperator::Inner(JoinConstraint::None) => Ok(SqlJoin { var, alias, on: None }), |
| 55 | JoinOperator::Inner(JoinConstraint::On(Expr::BinaryOp { |
| 56 | left, |
| 57 | op: BinaryOperator::Eq, |
| 58 | right, |
| 59 | })) if matches!(*left, Expr::Identifier(..) | Expr::CompoundIdentifier(..)) |
| 60 | && matches!(*right, Expr::Identifier(..) | Expr::CompoundIdentifier(..)) => |
| 61 | { |
| 62 | Ok(SqlJoin { |
| 63 | var, |
| 64 | alias, |
| 65 | on: Some(parse_expr( |
| 66 | Expr::BinaryOp { |
| 67 | left, |
| 68 | op: BinaryOperator::Eq, |
| 69 | right, |
| 70 | }, |
| 71 | 0, |
| 72 | )?), |
| 73 | }) |
| 74 | } |
| 75 | _ => Err(SqlUnsupported::JoinType.into()), |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /// Parse a table reference in a FROM clause |
| 80 | fn parse_relvar(expr: TableFactor) -> SqlParseResult<(SqlIdent, SqlIdent)> { |
nothing calls this directly
no test coverage detected