-
-
Notifications
You must be signed in to change notification settings - Fork 668
Open
Copy link
Description
Motivation
When using DeriveIntoActiveModel for my create and patch API/Serde endpoint input structs, there is no way to express:
- “If the user didn’t provide this field, use my custom default.”
- “Always use this set value for this required field.”
Currently, this requires either a manual implementation or explicitly setting those values every time the DeriveIntoActiveModel struct is used.
Example model that would benefit from this feature:
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(schema_name = "public", table_name = "file")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: I32,
pub creator_id: i32,
pub created_at: DateTime<Utc>, // <- set using current_time function
pub updater_id: Option<i32>,
pub updated_at: Option<DateTime<Utc>>,
pub deleted: bool, // <- set using my own default every time
}Proposed Solutions
I will link my PR below with more details.
Additional Information
I also believe the documentation for this derive macro is lacking.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels