diff --git a/01.workspace/heave/src/fun/sqlite_init_db.rs b/01.workspace/heave/src/fun/sqlite_init_db.rs index 9deb235..42ca808 100644 --- a/01.workspace/heave/src/fun/sqlite_init_db.rs +++ b/01.workspace/heave/src/fun/sqlite_init_db.rs @@ -6,7 +6,7 @@ pub fn run(path: &path::Path) { CREATE TABLE IF NOT EXISTS entity ( id TEXT PRIMARY KEY, class TEXT NOT NULL, - ref_date INTEGER NOT NULL + ref_date INTEGER ); CREATE TABLE IF NOT EXISTS attribute ( id TEXT, diff --git a/01.workspace/heave/src/fun/sqlite_map_row_to_entity.rs b/01.workspace/heave/src/fun/sqlite_map_row_to_entity.rs index 53daac1..ff6a973 100644 --- a/01.workspace/heave/src/fun/sqlite_map_row_to_entity.rs +++ b/01.workspace/heave/src/fun/sqlite_map_row_to_entity.rs @@ -3,11 +3,14 @@ use crate::*; pub fn run(row: &rusqlite::Row) -> rusqlite::Result { let id: String = row.get(0)?; let class: String = row.get(1)?; - let ref_date: u64 = row.get(2)?; - Ok(Entity::default() - .with_id(&id) - .with_class(&class) - .with_ref_date(ref_date)) + let ref_date: Option = row.get(2)?; + let entity = Entity { + id, + class, + ref_date, + ..Entity::default() + }; + Ok(entity) } // #[cfg(test)] diff --git a/01.workspace/heave/src/str/entity.rs b/01.workspace/heave/src/str/entity.rs index 61cfa9f..f617ec8 100644 --- a/01.workspace/heave/src/str/entity.rs +++ b/01.workspace/heave/src/str/entity.rs @@ -4,7 +4,7 @@ use crate::*; pub struct O { pub id: String, pub state: EntityState, - pub ref_date: u64, + pub ref_date: Option, pub class: String, pub attributes: std::collections::HashMap, } @@ -28,7 +28,7 @@ impl O { self } pub fn with_ref_date(mut self, ref_date: u64) -> Self { - self.ref_date = ref_date; + self.ref_date = Some(ref_date); self } pub fn with_attribute(mut self, id: &str, value: impl Into) -> Self {