aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/src/api_server.rs6
-rw-r--r--rust/tests/test_api_server.rs21
2 files changed, 24 insertions, 3 deletions
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index d172cb16..00d5cdde 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -807,9 +807,9 @@ impl Server {
if !new_abstracts.is_empty() {
// Sort of an "upsert"; only inserts new abstract rows if they don't already exist
insert_into(abstracts::table)
- .values(new_abstracts)
- //.on_conflict(abstracts::sha1)
- //.do_nothing()
+ .values(&new_abstracts)
+ .on_conflict(abstracts::sha1)
+ .do_nothing()
.execute(conn)?;
}
let release_abstract_rows: Vec<ReleaseRevAbstractNewRow> = abstract_list
diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs
index f43101c0..ca2d8df2 100644
--- a/rust/tests/test_api_server.rs
+++ b/rust/tests/test_api_server.rs
@@ -797,6 +797,27 @@ fn test_abstracts() {
None,
);
+ // Same abstracts; checking that re-inserting works
+ check_response(
+ request::post(
+ "http://localhost:9411/v0/release",
+ headers.clone(),
+ r#"{"title": "some paper again",
+ "abstracts": [
+ {"lang": "zh",
+ "mimetype": "text/plain",
+ "content": "some rando abstract 24iu3i25u2" },
+ {"lang": "en",
+ "mimetype": "application/xml+jats",
+ "content": "some other abstract 99139405" }
+ ]
+ }"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
check_response(