From 97f6417a58c0ec3c897f9634d21e705b4e37d7b6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 16 Feb 2022 20:02:17 -0800 Subject: rust: don't set prev_rev on re-update if entity is created This applies when re-editing any entity within an editgroup, when the entity does not yet exist other than the current editgroup. The current behavior was resulting in "updated" status, with "prev_rev" pointing to a revision which never existing in the catalog (aka, had never been merged). --- rust/src/entity_crud.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'rust') diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs index f48246a5..e8f63d0c 100644 --- a/rust/src/entity_crud.rs +++ b/rust/src/entity_crud.rs @@ -410,10 +410,11 @@ macro_rules! generic_db_update { fn db_update(&self, conn: &DbConn, edit_context: &EditContext, ident: FatcatId) -> Result { let current: Self::IdentRow = $ident_table::table.find(ident.to_uuid()).first(conn)?; let no_redirect: Option = None; - // Don't set prev_rev if current status is redirect - let prev_rev = match current.redirect_id { - Some(_) => None, - None => current.rev_id, + + // Don't set prev_rev if current state is 'redirect' or 'wip' + let prev_rev = match (current.redirect_id, current.is_live) { + (Some(_), _) | (_, false) => None, + (None, true) => current.rev_id, }; if self.state.is_none() { -- cgit v1.2.3