MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / fetch_page

Function fetch_page

src/executor/paginator.rs:407–434  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

405
406 #[smol_potat::test]
407 async fn fetch_page() -> Result<(), DbErr> {
408 let (db, pages) = setup();
409
410 let paginator = fruit::Entity::find().paginate(&db, 2);
411
412 assert_eq!(paginator.fetch_page(0).await?, pages[0].clone());
413 assert_eq!(paginator.fetch_page(1).await?, pages[1].clone());
414 assert_eq!(paginator.fetch_page(2).await?, pages[2].clone());
415
416 let mut select = SelectStatement::new()
417 .exprs([
418 Expr::col((fruit::Entity, fruit::Column::Id)),
419 Expr::col((fruit::Entity, fruit::Column::Name)),
420 Expr::col((fruit::Entity, fruit::Column::CakeId)),
421 ])
422 .from(fruit::Entity)
423 .to_owned();
424
425 let query_builder = db.get_database_backend();
426 let stmts = [
427 query_builder.build(select.clone().offset(0).limit(2)),
428 query_builder.build(select.clone().offset(2).limit(2)),
429 query_builder.build(select.offset(4).limit(2)),
430 ];
431
432 assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
433 Ok(())
434 }
435
436 #[smol_potat::test]
437 async fn fetch_page_raw() -> Result<(), DbErr> {

Callers

nothing calls this directly

Calls 9

paginateMethod · 0.80
exprsMethod · 0.80
limitMethod · 0.80
offsetMethod · 0.80
setupFunction · 0.70
newFunction · 0.50
fromMethod · 0.45
get_database_backendMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected