]> Untitled Git - lemmy.git/blobdiff - lemmy_db/src/source/community.rs
Merge branch 'main' into move_views_to_diesel
[lemmy.git] / lemmy_db / src / source / community.rs
index ea7a028e1f863e2831edea344b1cdb0d11eee31b..84db0c7c418c70f5056a69a867b0ae8a23123d99 100644 (file)
@@ -375,6 +375,9 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
     use crate::schema::community_follower::dsl::*;
     insert_into(community_follower)
       .values(community_follower_form)
+      .on_conflict((community_id, user_id))
+      .do_update()
+      .set(community_follower_form)
       .get_result::<Self>(conn)
   }
   fn follow_accepted(conn: &PgConnection, community_id_: i32, user_id_: i32) -> Result<Self, Error>