mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-03 03:33:50 +00:00
fix removal of post.instance_id (#5562)
this was originally removed in #5546, but #5515 introduced a new usage of it. due to the order of PR merges this slipped through and broke the build on main. fixes #5561
This commit is contained in:
parent
192344231c
commit
8b7b3ce072
2 changed files with 13 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
diesel::{DecoratableTarget, OptionalExtension},
|
||||
newtypes::{CommentId, DbUrl, InstanceId, PersonId},
|
||||
schema::{comment, comment_actions, post},
|
||||
schema::{comment, comment_actions, community, post},
|
||||
source::comment::{
|
||||
Comment,
|
||||
CommentActions,
|
||||
|
@ -26,6 +26,7 @@ use diesel::{
|
|||
result::Error,
|
||||
update,
|
||||
ExpressionMethods,
|
||||
JoinOnDsl,
|
||||
QueryDsl,
|
||||
};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -78,8 +79,9 @@ impl Comment {
|
|||
// Diesel can't update from join unfortunately, so you'll need to loop over these
|
||||
let comment_ids = comment::table
|
||||
.inner_join(post::table)
|
||||
.inner_join(community::table.on(post::community_id.eq(community::id)))
|
||||
.filter(comment::creator_id.eq(creator_id))
|
||||
.filter(post::instance_id.eq(instance_id))
|
||||
.filter(community::instance_id.eq(instance_id))
|
||||
.select(comment::id)
|
||||
.load::<CommentId>(conn)
|
||||
.await?;
|
||||
|
|
|
@ -162,7 +162,15 @@ impl Post {
|
|||
}
|
||||
|
||||
if let Some(for_instance_id) = for_instance_id {
|
||||
update = update.filter(post::instance_id.eq(for_instance_id));
|
||||
// Diesel can't update from join unfortunately, so you'll need to loop over these
|
||||
let post_ids = post::table
|
||||
.inner_join(community::table)
|
||||
.filter(post::creator_id.eq(for_creator_id))
|
||||
.filter(community::instance_id.eq(for_instance_id))
|
||||
.select(post::id)
|
||||
.load::<PostId>(conn)
|
||||
.await?;
|
||||
update = update.filter(post::id.eq_any(post_ids));
|
||||
}
|
||||
|
||||
update
|
||||
|
|
Loading…
Reference in a new issue