diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index 73882a99e..3be5a3913 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -32,8 +32,8 @@ where Self::Table: FilterDsl::PrimaryKey, Self::IdType>>, dsl::Filter::PrimaryKey, Self::IdType>>: LimitDsl + Send, - for<'query2> dsl::Limit::PrimaryKey, Self::IdType>>>: - Send + LoadQuery<'query2, AsyncPgConnection, Self> + 'query2, + for<'query> dsl::Limit::PrimaryKey, Self::IdType>>>: + Send + LoadQuery<'query, AsyncPgConnection, Self> + 'query, <::Table as Table>::PrimaryKey: ExpressionMethods + Send, <<::Table as Table>::PrimaryKey as Expression>::SqlType: SqlType + TypedExpressionType, @@ -54,13 +54,10 @@ where .await }*/ async fn read(pool: &mut DbPool<'_>, id: Self::IdType) -> Result { - let mut conn = get_conn(pool).await?; - let col = Self::table().primary_key(); // FindDsl is not used because it uses a private trait - let query = FilterDsl::filter(Self::table(), ExpressionMethods::eq(col, id)); - let conn_ref = &mut *conn; - let future = RunQueryDsl::first::(query, conn_ref); - future.await + let query = Self::table().filter(Self::table().primary_key().eq(id)); + let conn = &mut *get_conn(pool).await?; + query.first::(conn).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. async fn update(