]> Untitled Git - lemmy.git/blobdiff - lemmy_db/src/source/user_mention.rs
Merge branch 'main' into move_views_to_diesel
[lemmy.git] / lemmy_db / src / source / user_mention.rs
index ed5c2c797bc8c0ac5a2ccdfb0d3f608b7fb0fda6..bf53cb4200504854fbdaecce9515158fe1eec54a 100644 (file)
@@ -30,8 +30,13 @@ impl Crud<UserMentionForm> for UserMention {
 
   fn create(conn: &PgConnection, user_mention_form: &UserMentionForm) -> Result<Self, Error> {
     use crate::schema::user_mention::dsl::*;
+    // since the return here isnt utilized, we dont need to do an update
+    // but get_result doesnt return the existing row here
     insert_into(user_mention)
       .values(user_mention_form)
+      .on_conflict((recipient_id, comment_id))
+      .do_update()
+      .set(user_mention_form)
       .get_result::<Self>(conn)
   }