database set current sheet

This commit is contained in:
Abraham Toriz 2021-07-15 11:48:49 -05:00
parent 28f041831b
commit b531f8ca20
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
2 changed files with 7 additions and 0 deletions

View File

@ -117,6 +117,7 @@ mod tests {
let mut err = Vec::new();
let config = Default::default();
db.init().unwrap();
db.set_current_sheet("sheet2").unwrap();
db.entry_insert(Utc.ymd(2021, 1, 1).and_hms(0, 0, 0), None, None, "_archived".into()).unwrap();
db.entry_insert(Utc.ymd(2021, 1, 1).and_hms(0, 0, 0), None, None, "sheet1".into()).unwrap();

View File

@ -147,6 +147,12 @@ pub trait Database {
Ok(results.into_iter().next().map(|m| m.value))
}
fn set_current_sheet(&mut self, sheet: &str) -> Result<()> {
self.execute("INSERT INTO meta (key, value) VALUES ('current_sheet', ?1)", &[&sheet])?;
Ok(())
}
fn version(&self) -> Result<DBVersion> {
let results = self.meta_query("select * from meta where key='database_version'", &[])?;