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