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

Function inline_params

nodedb/src/control/server/native/dispatch/sql.rs:475–489  ·  view source on GitHub ↗

Substitute `$N` placeholders in `sql` with the rendered SQL literal form of each value. Returns the new SQL or a typed error message suitable for `42P02`.

(sql: &str, params: &[Value])

Source from the content-addressed store, hash-verified

473/// form of each value. Returns the new SQL or a typed error message
474/// suitable for `42P02`.
475fn inline_params(sql: &str, params: &[Value]) -> Result<String, String> {
476 // Render every value first so a render failure aborts the whole
477 // substitution rather than partially rewriting placeholders — a
478 // partially-rewritten SQL would re-create the silent-wrong pattern
479 // the trait contract guards against.
480 let literals: Vec<String> = params
481 .iter()
482 .map(value_to_sql_literal)
483 .collect::<Result<Vec<_>, _>>()?;
484 Ok(
485 crate::control::server::pgwire::handler::prepared::sql_placeholder::rewrite_sql_placeholders(
486 sql, &literals,
487 ),
488 )
489}
490
491/// Render a `nodedb_types::Value` as a SQL literal usable in
492/// expression position.

Callers 1

handle_sqlFunction · 0.85

Calls 2

rewrite_sql_placeholdersFunction · 0.85
iterMethod · 0.45

Tested by

no test coverage detected