feat: make ref_date optional
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -3,11 +3,14 @@ use crate::*;
|
||||
pub fn run(row: &rusqlite::Row) -> rusqlite::Result<Entity> {
|
||||
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<u64> = row.get(2)?;
|
||||
let entity = Entity {
|
||||
id,
|
||||
class,
|
||||
ref_date,
|
||||
..Entity::default()
|
||||
};
|
||||
Ok(entity)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::*;
|
||||
pub struct O {
|
||||
pub id: String,
|
||||
pub state: EntityState,
|
||||
pub ref_date: u64,
|
||||
pub ref_date: Option<u64>,
|
||||
pub class: String,
|
||||
pub attributes: std::collections::HashMap<String, Attribute>,
|
||||
}
|
||||
@@ -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<Value>) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user