(
&self,
query: &str,
params: &[Value],
)
| 18 | |
| 19 | impl 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)); |
no test coverage detected