Refactor calculation of next working set ID

As per Dustin's code-review comment
This commit is contained in:
dbr 2021-09-04 13:02:03 +10:00
parent 1d62799437
commit 89e9a42374

View file

@ -112,14 +112,14 @@ impl<'t> Txn<'t> {
fn get_next_working_set_number(&self) -> anyhow::Result<usize> { fn get_next_working_set_number(&self) -> anyhow::Result<usize> {
let t = self.get_txn()?; let t = self.get_txn()?;
let result: Option<usize> = t let next_id: Option<usize> = t
.query_row("SELECT COALESCE(MAX(id), 0) FROM working_set", [], |r| { .query_row("SELECT COALESCE(MAX(id), 0) + 1 FROM working_set", [], |r| {
r.get(0) r.get(0)
}) })
.optional() .optional()
.context("Getting highest working set ID")?; .context("Getting highest working set ID")?;
Ok(result.unwrap_or(0) + 1) Ok(next_id.unwrap_or(0))
} }
} }