MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / query

Method query

src/sql-server-util/src/lib.rs:188–214  ·  view source on GitHub ↗

Executes SQL statements in SQL Server, returning the resulting rows. Passthrough method for [`tiberius::Client::query`]. Note: The returned [`Future`] does not need to be awaited for the query to be sent. [`Future`]: std::future::Future

(
        &mut self,
        query: impl Into<Cow<'a, str>>,
        params: &[&dyn tiberius::ToSql],
    )

Source from the content-addressed store, hash-verified

186 ///
187 /// [`Future`]: std::future::Future
188 pub async fn query<'a>(
189 &mut self,
190 query: impl Into<Cow<'a, str>>,
191 params: &[&dyn tiberius::ToSql],
192 ) -> Result<SmallVec<[tiberius::Row; 1]>, SqlServerError> {
193 let (tx, rx) = tokio::sync::oneshot::channel();
194
195 let params = params
196 .iter()
197 .map(|p| OwnedColumnData::from(p.to_sql()))
198 .collect();
199 let kind = RequestKind::Query {
200 query: query.into().to_string(),
201 params,
202 };
203 self.tx
204 .send(Request { tx, kind })
205 .context("sending request")?;
206
207 let response = rx.await.context("channel")??;
208 match response {
209 Response::Rows(rows) => Ok(rows),
210 other @ Response::Execute { .. } | other @ Response::RowStream { .. } => Err(
211 SqlServerError::ProgrammingError(format!("expected Response::Rows, got {other:?}")),
212 ),
213 }
214 }
215
216 /// Executes SQL statements in SQL Server, returning a [`Stream`] of
217 /// resulting rows.

Calls 8

channelFunction · 0.85
collectMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
to_sqlMethod · 0.45
to_stringMethod · 0.45
contextMethod · 0.45
sendMethod · 0.45

Tested by 15

testPlatformEnvironmentFunction · 0.36
cleanupFunction · 0.36
fetchDataFunction · 0.36
get_min_lsnFunction · 0.36
get_min_lsnsFunction · 0.36
increment_lsnFunction · 0.36
cleanup_change_tableFunction · 0.36
get_cdc_table_columnsFunction · 0.36
get_ddl_historyFunction · 0.36