Remove pointless post_tags types.

This commit is contained in:
Dessalines 2024-12-19 18:07:59 -05:00
parent 9a0e050ee6
commit 776c5007a1
3 changed files with 25 additions and 44 deletions

View file

@ -10,11 +10,8 @@ use crate::{
InternalToCombinedView, InternalToCombinedView,
}; };
use diesel::{ use diesel::{
pg::Pg,
result::Error, result::Error,
sql_types,
BoolExpressionMethods, BoolExpressionMethods,
BoxableExpression,
ExpressionMethods, ExpressionMethods,
JoinOnDsl, JoinOnDsl,
NullableExpressionMethods, NullableExpressionMethods,
@ -103,18 +100,14 @@ impl PersonContentCombinedQuery {
let conn = &mut get_conn(pool).await?; let conn = &mut get_conn(pool).await?;
let post_tags: Box< let post_tags = post_tag::table
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table) .inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>( .select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)", "json_agg(tag.*)",
)) ))
.filter(post_tag::post_id.eq(post::id)) .filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false)) .filter(tag::deleted.eq(false))
.single_value(), .single_value();
);
// Notes: since the post_id and comment_id are optional columns, // Notes: since the post_id and comment_id are optional columns,
// many joins must use an OR condition. // many joins must use an OR condition.

View file

@ -8,11 +8,8 @@ use crate::{
InternalToCombinedView, InternalToCombinedView,
}; };
use diesel::{ use diesel::{
pg::Pg,
result::Error, result::Error,
sql_types,
BoolExpressionMethods, BoolExpressionMethods,
BoxableExpression,
ExpressionMethods, ExpressionMethods,
JoinOnDsl, JoinOnDsl,
NullableExpressionMethods, NullableExpressionMethods,
@ -97,18 +94,14 @@ impl PersonSavedCombinedQuery {
let conn = &mut get_conn(pool).await?; let conn = &mut get_conn(pool).await?;
let post_tags: Box< let post_tags = post_tag::table
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table) .inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>( .select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)", "json_agg(tag.*)",
)) ))
.filter(post_tag::post_id.eq(post::id)) .filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false)) .filter(tag::deleted.eq(false))
.single_value(), .single_value();
);
// Notes: since the post_id and comment_id are optional columns, // Notes: since the post_id and comment_id are optional columns,
// many joins must use an OR condition. // many joins must use an OR condition.

View file

@ -5,9 +5,7 @@ use diesel::{
pg::Pg, pg::Pg,
query_builder::AsQuery, query_builder::AsQuery,
result::Error, result::Error,
sql_types,
BoolExpressionMethods, BoolExpressionMethods,
BoxableExpression,
ExpressionMethods, ExpressionMethods,
JoinOnDsl, JoinOnDsl,
NullableExpressionMethods, NullableExpressionMethods,
@ -97,18 +95,15 @@ fn queries<'a>() -> Queries<
// If we want to filter by post tag we will have to add // 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 // 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)`). // exists (select 1 from post_community_post_tags where community_post_tag_id in (1,2,3,4)`).
let post_tags: Box< let post_tags = post_tag::table
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table) .inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>( .select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)", "json_agg(tag.*)",
)) ))
.filter(post_tag::post_id.eq(post_aggregates::post_id)) .filter(post_tag::post_id.eq(post_aggregates::post_id))
.filter(tag::deleted.eq(false)) .filter(tag::deleted.eq(false))
.single_value(), .single_value();
);
query query
.inner_join(person::table) .inner_join(person::table)
.inner_join(community::table) .inner_join(community::table)