refactor(sql): do not expose rusqlite Error type in query_map methods

We use query_and_then() instead of query_map() function now.
The difference is that row processing function
returns anyhow::Result, so simple fallible processing
like JSON parsing can be done inside of it
when calling query_map_vec() and query_map_collect()
without having to resort to query_map()
and iterating over all rows again afterwards.
This commit is contained in:
link2xt
2025-11-03 15:51:17 +00:00
parent 1db6ea70cc
commit 9c2a13b88e
12 changed files with 102 additions and 64 deletions

View File

@@ -202,7 +202,11 @@ impl Context {
.query_map(
"SELECT id, item FROM multi_device_sync ORDER BY id;",
(),
|row| Ok((row.get::<_, u32>(0)?, row.get::<_, String>(1)?)),
|row| {
let id: u32 = row.get(0)?;
let item: String = row.get(1)?;
Ok((id, item))
},
|rows| {
let mut ids = vec![];
let mut serialized = String::default();