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

Method query_one

src/driver/sqlx_postgres.rs:171–185  ·  view source on GitHub ↗
(&self, stmt: Statement)

Source from the content-addressed store, hash-verified

169 /// Get one result from a SQL query. Returns [Option::None] if no match was found
170 #[instrument(level = "trace")]
171 pub async fn query_one(&self, stmt: Statement) -> Result<Option<QueryResult>, DbErr> {
172 debug_print!("{}", stmt);
173
174 let query = sqlx_query(&stmt);
175 let mut conn = self.pool.acquire().await.map_err(sqlx_conn_acquire_err)?;
176 crate::metric::metric!(self.metric_callback, &stmt, {
177 match query.fetch_one(&mut *conn).await {
178 Ok(row) => Ok(Some(row.into())),
179 Err(err) => match err {
180 sqlx::Error::RowNotFound => Ok(None),
181 _ => Err(sqlx_error_to_query_err(err)),
182 },
183 }
184 })
185 }
186
187 /// Get the results of a query returning them as a Vec<[QueryResult]>
188 #[instrument(level = "trace")]

Callers

nothing calls this directly

Calls 1

sqlx_queryFunction · 0.70

Tested by

no test coverage detected