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 kvp;
|
||||||
mod migrations;
|
mod migrations;
|
||||||
|
|
||||||
|
|
|
@ -148,38 +148,18 @@ impl Db {
|
||||||
|
|
||||||
let tx = lock.transaction()?;
|
let tx = lock.transaction()?;
|
||||||
|
|
||||||
// When working with transactions in rusqlite, need to make this kind of scope
|
// 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.
|
// To make the borrow stuff work correctly. Don't know why, rust is wild.
|
||||||
let result = {
|
let result = {
|
||||||
let mut read_editors = tx
|
let mut editors_stmt = tx.prepare_cached(
|
||||||
.prepare_cached(
|
r#"
|
||||||
r#"
|
|
||||||
SELECT items.id, item_path.path
|
SELECT items.id, item_path.path
|
||||||
FROM items
|
FROM items
|
||||||
LEFT JOIN item_path
|
LEFT JOIN item_path
|
||||||
ON items.id = item_path.item_id
|
ON items.id = item_path.item_id
|
||||||
WHERE items.kind = "Editor";
|
WHERE items.kind = ?;
|
||||||
"#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;
|
|
||||||
",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let editors_iter = editors_stmt.query_map(
|
let editors_iter = editors_stmt.query_map(
|
||||||
[SerializedItemKind::Editor.to_string()],
|
[SerializedItemKind::Editor.to_string()],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use rusqlite_migration::{Migrations, M};
|
use rusqlite_migration::{Migrations, M};
|
||||||
|
|
||||||
// use crate::items::ITEMS_M_1;
|
// 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!!
|
// 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!!!!
|
// 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! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![
|
pub static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![
|
||||||
M::up(KVP_M_1_UP),
|
M::up(KVP_M_1_UP),
|
||||||
// M::up(ITEMS_M_1),
|
M::up(ITEMS_M_1),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue