(&self, stmt: Statement)
| 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")] |
nothing calls this directly
no test coverage detected