mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 10:51:29 +00:00
Remove pointless post_tags types.
This commit is contained in:
parent
9a0e050ee6
commit
776c5007a1
3 changed files with 25 additions and 44 deletions
|
@ -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>>,
|
.inner_join(tag::table)
|
||||||
> = Box::new(
|
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
||||||
post_tag::table
|
"json_agg(tag.*)",
|
||||||
.inner_join(tag::table)
|
))
|
||||||
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
.filter(post_tag::post_id.eq(post::id))
|
||||||
"json_agg(tag.*)",
|
.filter(tag::deleted.eq(false))
|
||||||
))
|
.single_value();
|
||||||
.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,
|
// 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.
|
||||||
|
|
|
@ -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>>,
|
.inner_join(tag::table)
|
||||||
> = Box::new(
|
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
||||||
post_tag::table
|
"json_agg(tag.*)",
|
||||||
.inner_join(tag::table)
|
))
|
||||||
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
.filter(post_tag::post_id.eq(post::id))
|
||||||
"json_agg(tag.*)",
|
.filter(tag::deleted.eq(false))
|
||||||
))
|
.single_value();
|
||||||
.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,
|
// 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.
|
||||||
|
|
|
@ -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>>,
|
.inner_join(tag::table)
|
||||||
> = Box::new(
|
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
||||||
post_tag::table
|
"json_agg(tag.*)",
|
||||||
.inner_join(tag::table)
|
))
|
||||||
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
|
.filter(post_tag::post_id.eq(post_aggregates::post_id))
|
||||||
"json_agg(tag.*)",
|
.filter(tag::deleted.eq(false))
|
||||||
))
|
.single_value();
|
||||||
.filter(post_tag::post_id.eq(post_aggregates::post_id))
|
|
||||||
.filter(tag::deleted.eq(false))
|
|
||||||
.single_value(),
|
|
||||||
);
|
|
||||||
query
|
query
|
||||||
.inner_join(person::table)
|
.inner_join(person::table)
|
||||||
.inner_join(community::table)
|
.inner_join(community::table)
|
||||||
|
|
Loading…
Reference in a new issue