You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of now, we can check if field of active model is changed, but we can't check if anything in whole active model has changed.
It would be great to just check if pear.is_changed() to make updated
Motivation
Now when i have active model and code like that:
async fn update_fruit(id: i64, color: Option<String>) -> Result<(), Error> {
let apple: Option<fruit::Model> = Fruit::find_by_id(id).one(db).await?;
let mut apple: Fruit::ActiveModel = apple.unwrap().into();
if color.is_some() {
apple.color = Set(color.unwrap());
}
let apple: fruit::Model = apple.update(db).await?;
Ok(())
}
this code will produce error, cos it try to make Update query like that: update fruit Set Where
With is_changed() method we could make:
if apple.is_changed() {
apple.update(db).await?;
}
so, no errors will be produced
The text was updated successfully, but these errors were encountered:
Summary
As of now, we can check if field of active model is changed, but we can't check if anything in whole active model has changed.
It would be great to just check if pear.is_changed() to make updated
Motivation
Now when i have active model and code like that:
this code will produce error, cos it try to make Update query like that:
update fruit Set Where
With is_changed() method we could make:
so, no errors will be produced
The text was updated successfully, but these errors were encountered: