Open godofdream opened 4 years ago
This seems reasonable, but I think I'd configure it this way instead of adding a new derive:
#[derive(Serialize, Deserialize, ToSql, FromSql, Debug)]
pub struct Product {
pub id: String,
pub data: ProductData,
}
#[derive(Serialize, Deserialize, ToSql, FromSql, Debug)]
#[postgres(json)]
pub struct ProductData {
pub a: String,
pub b: String,
}
One common case is to have a json column which should be deserialised to a struct. Currently the postgres_type Json doesn't work if you also want Serialize and Deserialize.
It would be nice to add a derive which implements ToSql using Json.
The following could be the derive.
As a Result the struct would now be: