aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 00:15:36 +0200
committerTeddy Wing2021-05-30 00:20:39 +0200
commit278db85ab836948bc11fe2d26da126fc7695c083 (patch)
tree079c19d9a165a391c684b8ba4c3d3a46b79a5d56
parent768b67c966e9a78864b450b6051974d096f1d412 (diff)
downloadreflectub-278db85ab836948bc11fe2d26da126fc7695c083.tar.bz2
database::repo_get: Don't need my own error for empty row
Sqlx already returns an appropriate error if no row was found.
-rw-r--r--Cargo.toml2
-rw-r--r--src/database.rs5
2 files changed, 2 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 588ee18..182ccdf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,4 +11,4 @@ tokio = { version = "1.6.1", features = ["macros", "rt"] }
[dependencies.sqlx]
version = "0.5.5"
-features = ["chrono", "macros", "runtime-tokio-rustls", "sqlite"]
+features = ["chrono", "runtime-tokio-rustls", "sqlite"]
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<Repo, Box<dyn std::error::Error>> {
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)),