Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Rebase fix - Reworking approach to sql for take
Mikayla Maki60ebe33518df
diff --git a/crates/db/src/db.rs b/crates/db/src/db.rsindex 2949acdb837..6f1ac7f59f6 100644--- a/crates/db/src/db.rs+++ b/crates/db/src/db.rs@@ -1,3 +1,4 @@+mod items;mod kvp;mod migrations;diff --git a/crates/db/src/items.rs b/crates/db/src/items.rsindex 87edbd2c00f..ed4a4f85e31 100644--- a/crates/db/src/items.rs+++ b/crates/db/src/items.rs@@ -148,38 +148,18 @@ 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 read_editors = 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 editors_stmt = tx.prepare_cached(+ r#"SELECT items.id, item_path.pathFROM itemsLEFT JOIN item_path- ON items.id = item_path.item_id- WHERE items.kind = "Editor";- "#r,- )?- .query_map([], |row| {- let buf: Vec<u8> = 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;- ",- )?;+ ON items.id = item_path.item_id+ WHERE items.kind = ?;+ "#,+ )?;let editors_iter = editors_stmt.query_map([SerializedItemKind::Editor.to_string()],diff --git a/crates/db/src/migrations.rs b/crates/db/src/migrations.rsindex 1000543d8dd..40e5d28b80d 100644--- a/crates/db/src/migrations.rs+++ b/crates/db/src/migrations.rs@@ -1,7 +1,7 @@use rusqlite_migration::{Migrations, M};// use crate::items::ITEMS_M_1;-use crate::kvp::KVP_M_1_UP;+use crate::{items::ITEMS_M_1, kvp::KVP_M_1_UP};// This must be ordered by development time! Only ever add new migrations to the end!!// Bad things will probably happen if you don't monotonically edit this vec!!!!@@ -10,6 +10,6 @@ use crate::kvp::KVP_M_1_UP;lazy_static::lazy_static! {pub static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![M::up(KVP_M_1_UP),- // M::up(ITEMS_M_1),+ M::up(ITEMS_M_1),]);}