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

Function convert_value_rows

nodedb-sql/src/planner/dml_helpers.rs:10–26  ·  view source on GitHub ↗
(
    columns: &[String],
    rows: &[Vec<ast::Expr>],
)

Source from the content-addressed store, hash-verified

8use crate::types::*;
9
10pub(super) fn convert_value_rows(
11 columns: &[String],
12 rows: &[Vec<ast::Expr>],
13) -> Result<Vec<Vec<(String, SqlValue)>>> {
14 rows.iter()
15 .map(|row| {
16 row.iter()
17 .enumerate()
18 .map(|(i, expr)| {
19 let col = columns.get(i).cloned().unwrap_or_else(|| format!("col{i}"));
20 let val = expr_to_sql_value(expr)?;
21 Ok((col, val))
22 })
23 .collect::<Result<Vec<_>>>()
24 })
25 .collect()
26}
27
28pub(super) fn expr_to_sql_value(expr: &ast::Expr) -> Result<SqlValue> {
29 match expr {

Callers 3

plan_insertFunction · 0.85
plan_upsertFunction · 0.85

Calls 4

expr_to_sql_valueFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected