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

Function fetch_and_next_raw

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

Source from the content-addressed store, hash-verified

672
673 #[smol_potat::test]
674 async fn fetch_and_next_raw() -> Result<(), DbErr> {
675 let (db, pages) = setup();
676
677 let mut paginator = fruit::Entity::find()
678 .from_raw_sql(RAW_STMT.clone())
679 .paginate(&db, 2);
680
681 assert_eq!(paginator.cur_page(), 0);
682 assert_eq!(paginator.fetch_and_next().await?, Some(pages[0].clone()));
683
684 assert_eq!(paginator.cur_page(), 1);
685 assert_eq!(paginator.fetch_and_next().await?, Some(pages[1].clone()));
686
687 assert_eq!(paginator.cur_page(), 2);
688 assert_eq!(paginator.fetch_and_next().await?, None);
689
690 let mut select = SelectStatement::new()
691 .exprs([
692 Expr::col((fruit::Entity, fruit::Column::Id)),
693 Expr::col((fruit::Entity, fruit::Column::Name)),
694 Expr::col((fruit::Entity, fruit::Column::CakeId)),
695 ])
696 .from(fruit::Entity)
697 .to_owned();
698
699 let query_builder = db.get_database_backend();
700 let stmts = [
701 query_builder.build(select.clone().offset(0).limit(2)),
702 query_builder.build(select.clone().offset(2).limit(2)),
703 query_builder.build(select.offset(4).limit(2)),
704 ];
705
706 assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
707 Ok(())
708 }
709
710 #[smol_potat::test]
711 async fn into_stream() -> Result<(), DbErr> {

Callers

nothing calls this directly

Calls 10

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