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

Method query_one

src/driver/sqlx_mysql.rs:140–154  ·  view source on GitHub ↗
(&self, stmt: Statement)

Source from the content-addressed store, hash-verified

138 /// Get one result from a SQL query. Returns [Option::None] if no match was found
139 #[instrument(level = "trace")]
140 pub async fn query_one(&self, stmt: Statement) -> Result<Option<QueryResult>, DbErr> {
141 debug_print!("{}", stmt);
142
143 let query = sqlx_query(&stmt);
144 let mut conn = self.pool.acquire().await.map_err(sqlx_conn_acquire_err)?;
145 crate::metric::metric!(self.metric_callback, &stmt, {
146 match query.fetch_one(&mut *conn).await {
147 Ok(row) => Ok(Some(row.into())),
148 Err(err) => match err {
149 sqlx::Error::RowNotFound => Ok(None),
150 _ => Err(sqlx_error_to_query_err(err)),
151 },
152 }
153 })
154 }
155
156 /// Get the results of a query returning them as a Vec<[QueryResult]>
157 #[instrument(level = "trace")]

Callers

nothing calls this directly

Calls 1

sqlx_queryFunction · 0.70

Tested by

no test coverage detected