aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-21 14:19:15 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-21 14:19:15 -0800
commit5bb99f5f60fedb33f8e1db5801632a04a8581377 (patch)
tree6f5761e17d3abd12b65d3b147036eeda55066110 /rust/src
parent1a15624e13bfe0a3bdddb1f0c5bf8940c9f04a04 (diff)
downloadfatcat-5bb99f5f60fedb33f8e1db5801632a04a8581377.tar.gz
fatcat-5bb99f5f60fedb33f8e1db5801632a04a8581377.zip
test prev_rev behavior
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/api_entity_crud.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/rust/src/api_entity_crud.rs b/rust/src/api_entity_crud.rs
index 0315f0a7..cf17a329 100644
--- a/rust/src/api_entity_crud.rs
+++ b/rust/src/api_entity_crud.rs
@@ -213,6 +213,11 @@ macro_rules! generic_db_update {
return Err(ErrorKind::InvalidEntityStateTransform(
"can't update an entity that doesn't exist yet".to_string()).into());
}
+ // Don't set prev_rev if current status is redirect
+ let prev_rev = match current.redirect_id {
+ Some(_) => None,
+ None => current.rev_id,
+ };
if self.state.is_none() {
@@ -245,7 +250,7 @@ macro_rules! generic_db_update {
$edit_table::ident_id.eq(&ident.to_uuid()),
$edit_table::rev_id.eq(target.rev_id),
$edit_table::redirect_id.eq(redirect_ident),
- $edit_table::prev_rev.eq(current.rev_id),
+ $edit_table::prev_rev.eq(prev_rev),
$edit_table::extra_json.eq(&self.edit_extra),
))
.get_result(conn)?;
@@ -264,7 +269,7 @@ macro_rules! generic_db_update {
$edit_table::ident_id.eq(&ident.to_uuid()),
$edit_table::rev_id.eq(&rev_id),
$edit_table::redirect_id.eq(no_redirect),
- $edit_table::prev_rev.eq(current.rev_id),
+ $edit_table::prev_rev.eq(prev_rev),
$edit_table::extra_json.eq(&self.edit_extra),
))
.get_result(conn)?;
@@ -280,7 +285,7 @@ macro_rules! generic_db_update {
$edit_table::ident_id.eq(&ident.to_uuid()),
$edit_table::rev_id.eq(&rev_id),
$edit_table::redirect_id.eq(no_redirect),
- $edit_table::prev_rev.eq(current.rev_id),
+ $edit_table::prev_rev.eq(prev_rev),
$edit_table::extra_json.eq(&self.edit_extra),
))
.get_result(conn)?;