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

Function fetch_raw

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

Source from the content-addressed store, hash-verified

501
502 #[smol_potat::test]
503 async fn fetch_raw() -> Result<(), DbErr> {
504 let (db, pages) = setup();
505
506 let mut paginator = fruit::Entity::find()
507 .from_raw_sql(RAW_STMT.clone())
508 .paginate(&db, 2);
509
510 assert_eq!(paginator.fetch().await?, pages[0].clone());
511 paginator.next();
512
513 assert_eq!(paginator.fetch().await?, pages[1].clone());
514 paginator.next();
515
516 assert_eq!(paginator.fetch().await?, pages[2].clone());
517
518 let mut select = SelectStatement::new()
519 .exprs([
520 Expr::col((fruit::Entity, fruit::Column::Id)),
521 Expr::col((fruit::Entity, fruit::Column::Name)),
522 Expr::col((fruit::Entity, fruit::Column::CakeId)),
523 ])
524 .from(fruit::Entity)
525 .to_owned();
526
527 let query_builder = db.get_database_backend();
528 let stmts = [
529 query_builder.build(select.clone().offset(0).limit(2)),
530 query_builder.build(select.clone().offset(2).limit(2)),
531 query_builder.build(select.offset(4).limit(2)),
532 ];
533
534 assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
535 Ok(())
536 }
537
538 #[smol_potat::test]
539 async fn num_pages() -> Result<(), DbErr> {

Callers

nothing calls this directly

Calls 11

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