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

Function fetch

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

Source from the content-addressed store, hash-verified

467
468 #[smol_potat::test]
469 async fn fetch() -> Result<(), DbErr> {
470 let (db, pages) = setup();
471
472 let mut paginator = fruit::Entity::find().paginate(&db, 2);
473
474 assert_eq!(paginator.fetch().await?, pages[0].clone());
475 paginator.next();
476
477 assert_eq!(paginator.fetch().await?, pages[1].clone());
478 paginator.next();
479
480 assert_eq!(paginator.fetch().await?, pages[2].clone());
481
482 let mut select = SelectStatement::new()
483 .exprs([
484 Expr::col((fruit::Entity, fruit::Column::Id)),
485 Expr::col((fruit::Entity, fruit::Column::Name)),
486 Expr::col((fruit::Entity, fruit::Column::CakeId)),
487 ])
488 .from(fruit::Entity)
489 .to_owned();
490
491 let query_builder = db.get_database_backend();
492 let stmts = [
493 query_builder.build(select.clone().offset(0).limit(2)),
494 query_builder.build(select.clone().offset(2).limit(2)),
495 query_builder.build(select.offset(4).limit(2)),
496 ];
497
498 assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
499 Ok(())
500 }
501
502 #[smol_potat::test]
503 async fn fetch_raw() -> Result<(), DbErr> {

Callers 2

from_requestMethod · 0.50
abortMethod · 0.50

Calls 10

paginateMethod · 0.80
nextMethod · 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