1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

mas-storage-pg: use fetch_optional instead of fetch_one and matching on the error

This commit is contained in:
Quentin Gliech
2023-07-20 17:13:15 +02:00
parent 802cf142fd
commit b60121346f
17 changed files with 63 additions and 122 deletions

View File

@@ -28,7 +28,7 @@ use ulid::Ulid;
use url::Url;
use uuid::Uuid;
use crate::{tracing::ExecuteExt, DatabaseError, DatabaseInconsistencyError, LookupResultExt};
use crate::{tracing::ExecuteExt, DatabaseError, DatabaseInconsistencyError};
/// An implementation of [`OAuth2AuthorizationGrantRepository`] for a PostgreSQL
/// connection
@@ -340,9 +340,8 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi
"#,
Uuid::from(id),
)
.fetch_one(&mut *self.conn)
.await
.to_option()?;
.fetch_optional(&mut *self.conn)
.await?;
let Some(res) = res else { return Ok(None) };
@@ -391,9 +390,8 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi
code,
)
.traced()
.fetch_one(&mut *self.conn)
.await
.to_option()?;
.fetch_optional(&mut *self.conn)
.await?;
let Some(res) = res else { return Ok(None) };