diff --git a/crates/db/src/catalog.rs b/crates/db/src/catalog.rs index 392e0ad..faad1c9 100644 --- a/crates/db/src/catalog.rs +++ b/crates/db/src/catalog.rs @@ -188,6 +188,12 @@ pub async fn update_object( return Ok(false); }; + let changes = update_changes(&old.to_input(), input); + if changes.is_empty() { + // No-op: don't touch updated_at or the audit log. + return Ok(true); + } + sqlx::query( "UPDATE object SET \ object_number = $2, object_name = $3, number_of_objects = $4, \ @@ -208,21 +214,17 @@ pub async fn update_object( .execute(&mut *conn) .await?; - let changes = update_changes(&old.to_input(), input); - - if !changes.is_empty() { - audit::record( - &mut *conn, - &NewAuditEvent { - actor, - action: AuditAction::Updated, - entity_type: ENTITY_TYPE.to_owned(), - entity_id: id.to_uuid(), - changes, - }, - ) - .await?; - } + audit::record( + &mut *conn, + &NewAuditEvent { + actor, + action: AuditAction::Updated, + entity_type: ENTITY_TYPE.to_owned(), + entity_id: id.to_uuid(), + changes, + }, + ) + .await?; Ok(true) }