mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-04 06:34:26 +00:00
Rebase fix - Reworking approach to sql for take
This commit is contained in:
parent
72c1ee904b
commit
60ebe33518
3 changed files with 12 additions and 31 deletions
|
@ -1,3 +1,4 @@
|
|||
mod items;
|
||||
mod kvp;
|
||||
mod migrations;
|
||||
|
||||
|
|
|
@ -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.path
|
||||
FROM items
|
||||
LEFT 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()],
|
||||
|
|
|
@ -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),
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue