Closed Elieroz closed 5 days ago
I find the idea interesting but I'm concerned about the fact that activating the serde
feature will implement Serialize
and Deserialize
indiscrimately for all Insert
structs.
I think there should be additional attributes to opt-in to this, eg (naming for these attributes is bad but I only thought about it for 30sec 😅):
#[derive(Debug, ormx::Table)]
#[ormx(table = "foo", id = id, insertable, insertable_derive_deserialize, insertable_derive_serialize)]
struct Foo {
id: i32,
bar: String,
}
Oh, I just assumed this would always be desirable. Whoops!
I'll follow your suggestion!
This can be achieved with
#[ormx(table = "foo", id = id, insertable = #[derive(Serialize) InsertFoo)]
I added a new feature called
serde
to deriveserde
'sSerialize
andDeserialize
traits for the generated insert structs when enabled.This way, these structs can be easily used in web applications built with frameworks or libraries that require the structs that represent a request's body to be serializable to and deserializable from a JSON document.