-
-
Notifications
You must be signed in to change notification settings - Fork 692
Unable to (de)serialize nested JSON Blobs using serde Traits #676
Copy link
Copy link
Closed
Milestone
Description
Description
We have a database schema where we save (from the db pov) untyped json blobs into the database + some metadata columns. We have a serde compatible struct for describing the blobs on the rust side and expected to be able to use the #[sea_orm(db_type = "Json")] as annotation to be able to deserialize the JSON col into the rust struct on select.
Steps to Reproduce
Rust
use some_external_crate::priding::our::type::SomeStruct;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "table_name")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
#[sea_orm(db_type = "Json")]
pub details: SomeStruct,
pub refreshed_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
...SQL
CREATE TABLE table_name (
id varchar(64) PRIMARY KEY,
refreshed_at timestamptz NOT NULL,
details jsonb NOT NULL
);Expected Behavior
The details field of the Model should be deserialized from json / jsonb columns into the SomeStruct type in rust.
Actual Behavior
"the trait bound `sea_orm::Value: From<SomeStruct>` is not satisfied"
Reproduces How Often
Every time.
Versions
0.7.1
Additional Information
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done