From 776c5007a1baa50b320bd6186768126ce2bc4780 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 19 Dec 2024 18:07:59 -0500 Subject: [PATCH] Remove pointless post_tags types. --- .../src/person_content_combined_view.rs | 23 +++++++------------ .../src/person_saved_combined_view.rs | 23 +++++++------------ crates/db_views/src/post_view.rs | 23 ++++++++----------- 3 files changed, 25 insertions(+), 44 deletions(-) diff --git a/crates/db_views/src/person_content_combined_view.rs b/crates/db_views/src/person_content_combined_view.rs index 0811fbf22..0da4ca359 100644 --- a/crates/db_views/src/person_content_combined_view.rs +++ b/crates/db_views/src/person_content_combined_view.rs @@ -10,11 +10,8 @@ use crate::{ InternalToCombinedView, }; use diesel::{ - pg::Pg, result::Error, - sql_types, BoolExpressionMethods, - BoxableExpression, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, @@ -103,18 +100,14 @@ impl PersonContentCombinedQuery { let conn = &mut get_conn(pool).await?; - let post_tags: Box< - dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, - > = Box::new( - post_tag::table - .inner_join(tag::table) - .select(diesel::dsl::sql::( - "json_agg(tag.*)", - )) - .filter(post_tag::post_id.eq(post::id)) - .filter(tag::deleted.eq(false)) - .single_value(), - ); + let post_tags = post_tag::table + .inner_join(tag::table) + .select(diesel::dsl::sql::( + "json_agg(tag.*)", + )) + .filter(post_tag::post_id.eq(post::id)) + .filter(tag::deleted.eq(false)) + .single_value(); // Notes: since the post_id and comment_id are optional columns, // many joins must use an OR condition. diff --git a/crates/db_views/src/person_saved_combined_view.rs b/crates/db_views/src/person_saved_combined_view.rs index 3c61d9705..94b93e9d8 100644 --- a/crates/db_views/src/person_saved_combined_view.rs +++ b/crates/db_views/src/person_saved_combined_view.rs @@ -8,11 +8,8 @@ use crate::{ InternalToCombinedView, }; use diesel::{ - pg::Pg, result::Error, - sql_types, BoolExpressionMethods, - BoxableExpression, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, @@ -97,18 +94,14 @@ impl PersonSavedCombinedQuery { let conn = &mut get_conn(pool).await?; - let post_tags: Box< - dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, - > = Box::new( - post_tag::table - .inner_join(tag::table) - .select(diesel::dsl::sql::( - "json_agg(tag.*)", - )) - .filter(post_tag::post_id.eq(post::id)) - .filter(tag::deleted.eq(false)) - .single_value(), - ); + let post_tags = post_tag::table + .inner_join(tag::table) + .select(diesel::dsl::sql::( + "json_agg(tag.*)", + )) + .filter(post_tag::post_id.eq(post::id)) + .filter(tag::deleted.eq(false)) + .single_value(); // Notes: since the post_id and comment_id are optional columns, // many joins must use an OR condition. diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index fc2afe844..c40e62f1a 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -5,9 +5,7 @@ use diesel::{ pg::Pg, query_builder::AsQuery, result::Error, - sql_types, BoolExpressionMethods, - BoxableExpression, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, @@ -97,18 +95,15 @@ fn queries<'a>() -> Queries< // If we want to filter by post tag we will have to add // separate logic below since this subquery can't affect filtering, but it is simple (`WHERE // exists (select 1 from post_community_post_tags where community_post_tag_id in (1,2,3,4)`). - let post_tags: Box< - dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, - > = Box::new( - post_tag::table - .inner_join(tag::table) - .select(diesel::dsl::sql::( - "json_agg(tag.*)", - )) - .filter(post_tag::post_id.eq(post_aggregates::post_id)) - .filter(tag::deleted.eq(false)) - .single_value(), - ); + let post_tags = post_tag::table + .inner_join(tag::table) + .select(diesel::dsl::sql::( + "json_agg(tag.*)", + )) + .filter(post_tag::post_id.eq(post_aggregates::post_id)) + .filter(tag::deleted.eq(false)) + .single_value(); + query .inner_join(person::table) .inner_join(community::table)