Return `(column, literal, residual_expr)` for an equality found anywhere in a right-leaning AND conjunction tree, or `None` if no bare column-equals-literal predicate exists. The residual preserves every sibling conjunct in their original order; `None` means the expression was a bare equality with nothing left behind.
(expr: &SqlExpr)
| 314 | /// every sibling conjunct in their original order; `None` means the |
| 315 | /// expression was a bare equality with nothing left behind. |
| 316 | fn split_equality_from_expr(expr: &SqlExpr) -> Option<(String, SqlValue, Option<SqlExpr>)> { |
| 317 | // Gather the conjuncts of a top-level AND chain left-to-right. |
| 318 | let mut conjuncts: Vec<SqlExpr> = Vec::new(); |
| 319 | flatten_and(expr, &mut conjuncts); |
| 320 | |
| 321 | // Find the first conjunct that is a bare column-equals-literal. |
| 322 | let eq_idx = conjuncts.iter().position(is_column_eq_literal)?; |
| 323 | let eq = conjuncts.remove(eq_idx); |
| 324 | let (col, lit) = match eq { |
| 325 | SqlExpr::BinaryOp { left, op, right } => match (*left, op, *right) { |
| 326 | (SqlExpr::Column { name, .. }, BinaryOp::Eq, SqlExpr::Literal(v)) => (name, v), |
| 327 | (SqlExpr::Literal(v), BinaryOp::Eq, SqlExpr::Column { name, .. }) => (name, v), |
| 328 | _ => return None, |
| 329 | }, |
| 330 | _ => return None, |
| 331 | }; |
| 332 | |
| 333 | let residual = rebuild_and(conjuncts); |
| 334 | Some((col, lit, residual)) |
| 335 | } |
| 336 | |
| 337 | /// Append every leaf of a right-leaning `AND` tree to `out`. Non-AND |
| 338 | /// expressions are a single leaf. |
no test coverage detected