|
@@ -444,14 +444,50 @@ mod delete_test {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
#[cfg(test)]
|
|
|
-mod query_macro_test {
|
|
|
+mod datatypes {
|
|
|
+ use crate::prelude::*;
|
|
|
+
|
|
|
+ #[derive(crate::Entity,serde::Serialize,serde::Deserialize,PartialEq,Debug)]
|
|
|
+ #[microrm_internal]
|
|
|
+ pub struct ValueStore {
|
|
|
+ pub b: bool,
|
|
|
+ pub i_8: i8,
|
|
|
+ pub u_8: u8,
|
|
|
+ pub i_16: i16,
|
|
|
+ pub u_16: u16,
|
|
|
+ pub i_32: i32,
|
|
|
+ pub u_32: u32,
|
|
|
+ pub i_64: i64,
|
|
|
+ pub u_64: u64,
|
|
|
+ pub s: String,
|
|
|
+ pub f_64: f64,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#[test]
|
|
|
- fn simple_select() {
|
|
|
- microrm_macros::query!{
|
|
|
- SELECT A,B,C FROM Something WHERE ID = ?
|
|
|
- }
|
|
|
+ fn store_load_datatypes() {
|
|
|
+ let schema = crate::Schema::new().entity::<ValueStore>();
|
|
|
+ let db = crate::DB::new_in_memory(schema).unwrap();
|
|
|
+
|
|
|
+ let test_values = ValueStore {
|
|
|
+ b: false,
|
|
|
+ i_8: 42i8,
|
|
|
+ u_8: 142u8,
|
|
|
+ i_16: 320i16,
|
|
|
+ u_16: 20000u16,
|
|
|
+ i_32: 1i32 << 20,
|
|
|
+ u_32: 3u32 << 30,
|
|
|
+ i_64: 1i64 << 40,
|
|
|
+ u_64: 3u64 << 62,
|
|
|
+ s: "this is a test".to_string(),
|
|
|
+ f_64: 23.140692632779263f64
|
|
|
+ };
|
|
|
+
|
|
|
+ let id = db.query_interface().add(&test_values).expect("failed to add ValueStore");
|
|
|
+
|
|
|
+ let all = db.query_interface().get().by_id(&id).all().expect("failed to get by id");
|
|
|
+ assert_eq!(all.len(), 1);
|
|
|
+ assert_eq!(all[0].as_ref(), &test_values);
|
|
|
}
|
|
|
}
|
|
|
-*/
|