MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / convert_expr_inner

Function convert_expr_inner

nodedb/src/control/planner/sql_plan_convert/expr.rs:28–265  ·  view source on GitHub ↗
(expr: &SqlExpr, qualify: bool)

Source from the content-addressed store, hash-verified

26}
27
28fn convert_expr_inner(expr: &SqlExpr, qualify: bool) -> crate::bridge::expr_eval::SqlExpr {
29 use crate::bridge::expr_eval::SqlExpr as BExpr;
30 match expr {
31 SqlExpr::Column { table, name } => {
32 // `EXCLUDED.col` references the row proposed for insertion in
33 // `INSERT ... ON CONFLICT DO UPDATE`. Emit the dedicated
34 // variant so the upsert handler can resolve against the
35 // incoming row via `eval_with_excluded`. The table qualifier
36 // comes in already-normalized (lowercased) from the parser.
37 if table
38 .as_deref()
39 .is_some_and(|t| t.eq_ignore_ascii_case("excluded"))
40 {
41 return BExpr::ExcludedColumn(name.clone());
42 }
43 if qualify {
44 BExpr::Column(nodedb_sql::planner::qualified_name(table.as_deref(), name))
45 } else {
46 BExpr::Column(name.clone())
47 }
48 }
49 SqlExpr::Literal(v) => BExpr::Literal(sql_value_to_nodedb_value(v)),
50 SqlExpr::BinaryOp { left, op, right } => BExpr::BinaryOp {
51 left: Box::new(convert_expr_inner(left, qualify)),
52 op: match op {
53 nodedb_sql::types::BinaryOp::Add => crate::bridge::expr_eval::BinaryOp::Add,
54 nodedb_sql::types::BinaryOp::Sub => crate::bridge::expr_eval::BinaryOp::Sub,
55 nodedb_sql::types::BinaryOp::Mul => crate::bridge::expr_eval::BinaryOp::Mul,
56 nodedb_sql::types::BinaryOp::Div => crate::bridge::expr_eval::BinaryOp::Div,
57 nodedb_sql::types::BinaryOp::Mod => crate::bridge::expr_eval::BinaryOp::Mod,
58 nodedb_sql::types::BinaryOp::Eq => crate::bridge::expr_eval::BinaryOp::Eq,
59 nodedb_sql::types::BinaryOp::Ne => crate::bridge::expr_eval::BinaryOp::NotEq,
60 nodedb_sql::types::BinaryOp::Gt => crate::bridge::expr_eval::BinaryOp::Gt,
61 nodedb_sql::types::BinaryOp::Ge => crate::bridge::expr_eval::BinaryOp::GtEq,
62 nodedb_sql::types::BinaryOp::Lt => crate::bridge::expr_eval::BinaryOp::Lt,
63 nodedb_sql::types::BinaryOp::Le => crate::bridge::expr_eval::BinaryOp::LtEq,
64 nodedb_sql::types::BinaryOp::And => crate::bridge::expr_eval::BinaryOp::And,
65 nodedb_sql::types::BinaryOp::Or => crate::bridge::expr_eval::BinaryOp::Or,
66 nodedb_sql::types::BinaryOp::Concat => crate::bridge::expr_eval::BinaryOp::Concat,
67 },
68 right: Box::new(convert_expr_inner(right, qualify)),
69 },
70 SqlExpr::Function { name, args, .. } => BExpr::Function {
71 name: name.clone(),
72 args: args
73 .iter()
74 .map(|a| convert_expr_inner(a, qualify))
75 .collect(),
76 },
77 SqlExpr::Case {
78 operand,
79 when_then,
80 else_expr,
81 } => BExpr::Case {
82 operand: operand
83 .as_ref()
84 .map(|e| Box::new(convert_expr_inner(e, qualify))),
85 when_thens: when_then

Callers 2

sql_expr_to_bridge_exprFunction · 0.70

Calls 10

qualified_nameFunction · 0.85
collectMethod · 0.80
cloneMethod · 0.45
iterMethod · 0.45
as_refMethod · 0.45
as_strMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected