You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for implementing this powerful db in Rust. I have got a model:
#[derive(Serialize,Deserialize,Debug)]#[native_model(id = 1, version = 1)]#[native_db]pubstructModel{#[primary_key]pubname:String,pubnetworks:Vec<Network>,}
The struct Network is defined in this way:
#[derive(Serialize,Deserialize,Debug)]pubstructNetwork{name:String,config:Rc<Config>,// Config is a struct containing many String membersinputs:Vec<u32>,optional_input:Option<u32>,input_to_value:HashMap<u32,u32>,registry:Rc<RefCell<Registry>>,cache:Arc<RwLock<Cache>>,// Cache is a struct with many HashSet and HashMap members}#[derive(Serialize,Deserialize,Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]pubstructBeh{members:Vec<u32>,beh_value:u64,}#[derive(Serialize,Deserialize,Debug,Default)]pubstructRegistry{pair_to_beh:HashMap<(u32,u32),Beh>,}
This model could be saved into a file without any problem. But when I read back the model and tried to remove(), update(), or upsert(), native_db threw an error IncorrectInputData. It seems the error was caused by the check current_item == item.value in concrete_remove() in transaction/internal/rw_transaction.rs (line 171):
@tklam Thank you for your message. I haven't had the time to look into it yet (I'll try during the week), but at first glance, the serialization of HashSet and HashMap might pose a problem because the order is not guaranteed.
You can run a test with native_model by simply trying to encode and decode your structure. And maybe try using a different serializer than the default one. And maybe use ordermap.
Thanks a lot. I tried encoding and decoding the above structs. native_db worked out of the box using the default serializer. There was no issue at all with HashSet and HashMap. Perhaps my setup was wrong; or it might because the structs listed here are in fact the simplified version of the actual structs in my project that they cannot reflect the real situation. Let me check it thoroughly.
Hi, thanks for implementing this powerful db in Rust. I have got a model:
The struct
Network
is defined in this way:This model could be saved into a file without any problem. But when I read back the model and tried to remove(), update(), or upsert(), native_db threw an error
IncorrectInputData
. It seems the error was caused by the checkcurrent_item == item.value
inconcrete_remove()
intransaction/internal/rw_transaction.rs
(line 171):So my questions are:
current_item == item.value
false?Thank you so much
The text was updated successfully, but these errors were encountered: