MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / query_one

Method query_one

src/driver/sqlx_sqlite.rs:158–172  ·  view source on GitHub ↗
(&self, stmt: Statement)

Source from the content-addressed store, hash-verified

156 /// Get one result from a SQL query. Returns [Option::None] if no match was found
157 #[instrument(level = "trace")]
158 pub async fn query_one(&self, stmt: Statement) -> Result<Option<QueryResult>, DbErr> {
159 debug_print!("{}", stmt);
160
161 let query = sqlx_query(&stmt);
162 let mut conn = self.pool.acquire().await.map_err(sqlx_conn_acquire_err)?;
163 crate::metric::metric!(self.metric_callback, &stmt, {
164 match query.fetch_one(&mut *conn).await {
165 Ok(row) => Ok(Some(row.into())),
166 Err(err) => match err {
167 sqlx::Error::RowNotFound => Ok(None),
168 _ => Err(sqlx_error_to_query_err(err)),
169 },
170 }
171 })
172 }
173
174 /// Get the results of a query returning them as a Vec<[QueryResult]>
175 #[instrument(level = "trace")]

Callers 1

get_versionFunction · 0.45

Calls 1

sqlx_queryFunction · 0.70

Tested by

no test coverage detected