mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Refactor calculation of next working set ID
As per Dustin's code-review comment
This commit is contained in:
parent
1d62799437
commit
89e9a42374
1 changed files with 3 additions and 3 deletions
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue