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:
Richard Schwab 2025-03-31 09:44:55 +02:00 committed by GitHub
parent 192344231c
commit 8b7b3ce072
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View file

@ -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?;

View file

@ -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