diff --git a/.gitignore b/.gitignore index c403c34..4cb2679 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .idea/ +yopa/target diff --git a/yopa/src/data.rs b/yopa/src/data.rs index cdd24a2..11b41fc 100644 --- a/yopa/src/data.rs +++ b/yopa/src/data.rs @@ -3,8 +3,8 @@ use serde::{Serialize, Deserialize}; use crate::ID; use std::borrow::Cow; -use crate::StorageError; -use std::num::ParseIntError; + + use crate::model::DataType; /// Value of a particular type @@ -66,16 +66,14 @@ impl TypedValue { (TypedValue::Integer(i), DataType::Boolean) => Ok(TypedValue::Boolean(i != 0)), (e @ TypedValue::Decimal(_), DataType::Boolean) => Err(e), (b @ TypedValue::Boolean(_), DataType::Boolean) => Ok(b), - (s, _) => { - Err(s) - } + //(s, _) => Err(s) } } } #[cfg(test)] mod tests { - use crate::TypedValue; + use crate::data::TypedValue; use crate::model::DataType; #[test] diff --git a/yopa/src/lib.rs b/yopa/src/lib.rs index a1525d3..9c51b78 100644 --- a/yopa/src/lib.rs +++ b/yopa/src/lib.rs @@ -6,9 +6,9 @@ use model::{ObjectModel}; use insert::InsertObj; use itertools::Itertools; use std::borrow::Cow; -use model::Describe; + use insert::InsertValue; -use data::TypedValue; + mod cool; @@ -34,11 +34,11 @@ pub mod id { pub type ID = u64; lazy_static::lazy_static! { - static ref counter: parking_lot::Mutex = parking_lot::Mutex::new(0); + static ref COUNTER: parking_lot::Mutex = parking_lot::Mutex::new(0); } pub fn next_id() -> ID { - let mut m = counter.lock(); + let mut m = COUNTER.lock(); let v = *m; *m += 1; v @@ -219,7 +219,7 @@ impl InMemoryStorage { let mut values_by_id = values.into_iter().into_group_map_by(|iv| iv.model_id); let mut values_to_insert = vec![]; - for (id, prop) in self.prop_models.iter().filter(|(id, p)| p.parent_tpl_id == parent_id) { + for (id, prop) in self.prop_models.iter().filter(|(_id, p)| p.parent_tpl_id == parent_id) { if let Some(values) = values_by_id.remove(id) { if values.len() > 1 && !prop.multiple { return Err(StorageError::ConstraintViolation(format!("{} of {} cannot have multiple values", prop, obj_model).into())); @@ -258,7 +258,7 @@ impl InMemoryStorage { let mut relations_by_id = insobj.relations.into_iter().into_group_map_by(|ir| ir.model_id); let mut relations_to_insert = vec![]; - for (relation_model_id, relation_model) in self.rel_models.iter().filter(|(id, r)| r.object_tpl_id == obj_model_id) { + for (relation_model_id, relation_model) in self.rel_models.iter().filter(|(_id, r)| r.object_tpl_id == obj_model_id) { if let Some(instances) = relations_by_id.remove(relation_model_id) { if instances.len() > 1 && !relation_model.multiple { return Err(StorageError::ConstraintViolation(format!("{} of {} cannot be set multiply", relation_model, obj_model).into())); diff --git a/yopa/src/model.rs b/yopa/src/model.rs index 50c8df3..28edbca 100644 --- a/yopa/src/model.rs +++ b/yopa/src/model.rs @@ -1,7 +1,7 @@ //! Data model structs and enums use serde::{Serialize, Deserialize}; -use std::borrow::Cow; + use super::ID; use super::data::TypedValue; use std::fmt::{Display, Formatter};