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

Method execute_sql_with_params

nodedb-client/src/native/connection/mod.rs:252–273  ·  view source on GitHub ↗

Execute a SQL query with bound parameters and return the result. Bound parameters travel through `TextFields::sql_params` as a `Vec ` — zerompk's generic array encoding serialises each element via `Value`'s hand-rolled `ToMessagePack` impl so the canonical scalar variants round-trip without a lossy JSON step. The server inlines each value as a SQL literal before planning, so `$1`, `$2`, … p

(
        &mut self,
        sql: &str,
        params: &[nodedb_types::Value],
    )

Source from the content-addressed store, hash-verified

250 /// Empty `params` routes through the same opcode but omits the
251 /// field, equivalent to `execute_sql`.
252 pub async fn execute_sql_with_params(
253 &mut self,
254 sql: &str,
255 params: &[nodedb_types::Value],
256 ) -> NodeDbResult<QueryResult> {
257 let sql_params = if params.is_empty() {
258 None
259 } else {
260 Some(params.to_vec())
261 };
262 let resp = self
263 .send(
264 OpCode::Sql,
265 TextFields {
266 sql: Some(sql.to_string()),
267 sql_params,
268 ..Default::default()
269 },
270 )
271 .await?;
272 response_to_query_result(resp)
273 }
274
275 /// Execute a DDL command.
276 pub async fn execute_ddl(&mut self, sql: &str) -> NodeDbResult<QueryResult> {

Callers 1

execute_sql_implMethod · 0.80

Calls 5

response_to_query_resultFunction · 0.85
to_stringMethod · 0.80
is_emptyMethod · 0.45
to_vecMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected