Skip to content
Discussion options

You must be logged in to vote

you can't call Default::default() inside new() as it calls back into itself hence causing stack overflow.

impl ActiveModelBehavior for ActiveModel {
    fn new() -> Self {
        Self {
            status: ActiveValue::Set(0),
            create_time: ActiveValue::Set(chrono::Utc::now().into()),
            modify_time: ActiveValue::Set(chrono::Utc::now().into()),
            ..ActiveModelTrait::default()
        }
    }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Charlestar
Comment options

@tyt2y3
Comment options

Answer selected by Charlestar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants