Closed boan-anbo closed 2 years ago
Hey @boan-anbo, welcome!! You need a few more trait bounds to make Rust compiler satisfy with it.
use sea_orm::{Database, DbErr, EntityTrait, FromQueryResult, PaginatorTrait};
pub async fn query_with_generic_type<E, M>() -> Result<(), DbErr>
where
E: EntityTrait<Model = M>,
M: FromQueryResult + Sized + Send + Sync,
{
let db = Database::connect("CONNECTION").await?;
// find works with all()
let mut query_all = E::find().all(&db).await?;
// compiler complains about this line: `method not found in `sea_orm::Select<E>`
let mut query = E::find().paginate(&db, 50);
Ok(())
}
Thanks so much! It compiles now!
For some reason compiler (rustc 1.66.0) complains about not finding PaginatorTrait when used on EntityTrait (but works with actual entity).
Reproduction Repo
https://github.com/boan-anbo/sea-orm-paginator-error.git