mirror of https://github.com/LemmyNet/lemmy.git
Clean up default Crud::read and rename 'query2
parent
32ad580239
commit
e1797a8eb4
|
@ -32,8 +32,8 @@ where
|
||||||
Self::Table: FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>,
|
Self::Table: FilterDsl<dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>,
|
||||||
dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>:
|
dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>:
|
||||||
LimitDsl + Send,
|
LimitDsl + Send,
|
||||||
for<'query2> dsl::Limit<dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>:
|
for<'query> dsl::Limit<dsl::Filter<Self::Table, dsl::Eq<<Self::Table as Table>::PrimaryKey, Self::IdType>>>:
|
||||||
Send + LoadQuery<'query2, AsyncPgConnection, Self> + 'query2,
|
Send + LoadQuery<'query, AsyncPgConnection, Self> + 'query,
|
||||||
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
||||||
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
||||||
SqlType + TypedExpressionType,
|
SqlType + TypedExpressionType,
|
||||||
|
@ -54,13 +54,10 @@ where
|
||||||
.await
|
.await
|
||||||
}*/
|
}*/
|
||||||
async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error> {
|
async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result<Self, Error> {
|
||||||
let mut conn = get_conn(pool).await?;
|
|
||||||
let col = Self::table().primary_key();
|
|
||||||
// FindDsl is not used because it uses a private trait
|
// FindDsl is not used because it uses a private trait
|
||||||
let query = FilterDsl::filter(Self::table(), ExpressionMethods::eq(col, id));
|
let query = Self::table().filter(Self::table().primary_key().eq(id));
|
||||||
let conn_ref = &mut *conn;
|
let conn = &mut *get_conn(pool).await?;
|
||||||
let future = RunQueryDsl::first::<Self>(query, conn_ref);
|
query.first::<Self>(conn).await
|
||||||
future.await
|
|
||||||
}
|
}
|
||||||
/// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
/// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
||||||
async fn update(
|
async fn update(
|
||||||
|
|
Loading…
Reference in New Issue