Repo layer refactor.

This commit is contained in:
2026-10-08 22:18:50 +02:00
parent 3709fcbe02
commit 7732b0ecc5
11 changed files with 216 additions and 195 deletions
+8 -4
View File
@@ -59,9 +59,10 @@ where
let transaction = db::upsert(executor, encode(transaction))
.await
.map_err(classify_upsert_error)?
.try_map(decode)?;
.try_map(decode)?
.into();
Ok(transaction.into())
Ok(transaction)
}
fn classify_upsert_error(error: DatabaseError) -> RepositoryError {
@@ -82,7 +83,9 @@ pub async fn delete_by_id<'e, E>(executor: E, id: Uuid) -> Result<Delete, Reposi
where
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
{
Ok(db::delete_by_id(executor, id).await?.into())
let result = db::delete_by_id(executor, id).await?.into();
Ok(result)
}
fn decode(row: TransactionRow) -> Result<Transaction, DecodeError> {
@@ -180,6 +183,7 @@ mod tests {
#[test]
fn round_trips_through_rows() {
let transaction = decode(row()).unwrap();
assert_eq!(decode(encode(transaction.clone())).unwrap(), transaction);
let round_trip = decode(encode(transaction.clone())).unwrap();
assert_eq!(round_trip, transaction);
}
}