diff --git a/src/entity/active_model.rs b/src/entity/active_model.rs
index e4374864..d6680ff5 100644
--- a/src/entity/active_model.rs
+++ b/src/entity/active_model.rs
@@ -198,7 +198,8 @@ where
}
}
-/// Insert the model if primary key is unset, update otherwise
+/// Insert the model if primary key is unset, update otherwise.
+/// Only works if the entity has auto increment primary key.
pub async fn save_active_model(mut am: A, db: &Database) -> Result
where
A: ActiveModelBehavior + ActiveModelTrait + From,
@@ -229,6 +230,7 @@ where
{
let exec = E::insert(am).exec(db);
let res = exec.await?;
+ // TODO: if the entity does not have auto increment primary key, then last_insert_id is a wrong value
if res.last_insert_id != 0 {
let find = E::find_by(res.last_insert_id).one(db);
let res = find.await;