From 72c1ee904b7335ede76b421a33edb70c07342b2a Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 19 Oct 2022 09:33:16 -0700 Subject: [PATCH] Fix rebase - Broken tab --- crates/db/src/items.rs | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/crates/db/src/items.rs b/crates/db/src/items.rs index ed4a4f85e3..87edbd2c00 100644 --- a/crates/db/src/items.rs +++ b/crates/db/src/items.rs @@ -148,18 +148,38 @@ impl Db { let tx = lock.transaction()?; - // When working with transactions in rusqlite, need to make this kind of scope - // To make the borrow stuff work correctly. Don't know why, rust is wild. - let result = { - let mut editors_stmt = tx.prepare_cached( - r#" + // When working with transactions in rusqlite, need to make this kind of scope + // To make the borrow stuff work correctly. Don't know why, rust is wild. + let result = { + let mut read_editors = tx + .prepare_cached( + r#" SELECT items.id, item_path.path FROM items LEFT JOIN item_path - ON items.id = item_path.item_id - WHERE items.kind = ?; - "#, - )?; + ON items.id = item_path.item_id + WHERE items.kind = "Editor"; + "#r, + )? + .query_map([], |row| { + let buf: Vec = row.get(2)?; + let path: PathBuf = OsStr::from_bytes(&buf).into(); + + Ok(SerializedItem::Editor(id, path)) + })?; + + let mut read_stmt = tx.prepare_cached( + " + SELECT items.id, items.kind, item_path.path, item_query.query + FROM items + LEFT JOIN item_path + ON items.id = item_path.item_id + LEFT JOIN item_query + ON items.id = item_query.item_id + WHERE + ORDER BY items.id; + ", + )?; let editors_iter = editors_stmt.query_map( [SerializedItemKind::Editor.to_string()],