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

Method execute_sql_impl

nodedb-client/src/remote/client/sql_lifecycle.rs:20–53  ·  view source on GitHub ↗
(
        &self,
        query: &str,
        params: &[Value],
    )

Source from the content-addressed store, hash-verified

18
19impl NodeDbRemote {
20 pub(super) async fn execute_sql_impl(
21 &self,
22 query: &str,
23 params: &[Value],
24 ) -> NodeDbResult<QueryResult> {
25 // Empty params: route through `simple_query` so DDL works
26 // alongside SELECT/DML in the same trait method. The
27 // extended-query path (`Client::query`) requires a row
28 // description for DDL that the server does not provide,
29 // surfacing as a generic `db error`. The simple-query path
30 // sends a single Query message and returns CommandComplete
31 // for DDL or rows for SELECT in one round-trip.
32 let (columns, rows) = if params.is_empty() {
33 self.simple_query_raw(query).await?
34 } else {
35 let translated = translate_params(params)?;
36 // Upcast `&(dyn ToSql + Send + Sync)` → `&(dyn ToSql + Sync)`
37 // so the slice matches what `Client::query` expects.
38 let refs: Vec<&(dyn tokio_postgres::types::ToSql + Sync)> = translated
39 .iter()
40 .map(|b| {
41 let upcast: &(dyn tokio_postgres::types::ToSql + Sync) = b.as_ref();
42 upcast
43 })
44 .collect();
45 self.query_raw(query, &refs).await?
46 };
47
48 Ok(QueryResult {
49 columns,
50 rows,
51 rows_affected: 0,
52 })
53 }
54
55 pub(super) async fn undrop_collection_impl(&self, name: &str) -> NodeDbResult<()> {
56 let sql = format!("UNDROP COLLECTION {}", quote_identifier(name));

Callers 1

execute_sqlMethod · 0.45

Calls 7

translate_paramsFunction · 0.85
simple_query_rawMethod · 0.80
collectMethod · 0.80
query_rawMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected