From 278db85ab836948bc11fe2d26da126fc7695c083 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 May 2021 00:15:36 +0200 Subject: database::repo_get: Don't need my own error for empty row Sqlx already returns an appropriate error if no row was found. --- src/database.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/database.rs b/src/database.rs index a49675f..e4ca5e9 100644 --- a/src/database.rs +++ b/src/database.rs @@ -58,6 +58,7 @@ impl Db { ) -> Result> { let mut tx = self.connection.begin().await?; + // NOTE: Returns `RowNotFound` if not found. let row = sqlx::query("SELECT id, name FROM repositories where id = ?") .bind(id) .fetch_one(&mut tx) @@ -65,10 +66,6 @@ impl Db { tx.commit().await?; - if row.is_empty() { - return Err("not found".into()); - } - Ok( Repo { id: Some(row.get(0)), -- cgit v1.2.3