From 89e9a42374d096e3fcfdca6a32bb19746d04bb2a Mon Sep 17 00:00:00 2001 From: dbr Date: Sat, 4 Sep 2021 13:02:03 +1000 Subject: [PATCH] Refactor calculation of next working set ID As per Dustin's code-review comment --- taskchampion/src/storage/sqlite.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taskchampion/src/storage/sqlite.rs b/taskchampion/src/storage/sqlite.rs index 63fb3bad5..55f7f7793 100644 --- a/taskchampion/src/storage/sqlite.rs +++ b/taskchampion/src/storage/sqlite.rs @@ -112,14 +112,14 @@ impl<'t> Txn<'t> { fn get_next_working_set_number(&self) -> anyhow::Result { let t = self.get_txn()?; - let result: Option = t - .query_row("SELECT COALESCE(MAX(id), 0) FROM working_set", [], |r| { + let next_id: Option = t + .query_row("SELECT COALESCE(MAX(id), 0) + 1 FROM working_set", [], |r| { r.get(0) }) .optional() .context("Getting highest working set ID")?; - Ok(result.unwrap_or(0) + 1) + Ok(next_id.unwrap_or(0)) } }