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

Function having

tests/relational_tests.rs:382–484  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380
381#[sea_orm_macros::test]
382pub async fn having() {
383 // customers with orders with total equal to $90
384 let ctx = TestContext::new("test_having").await;
385 create_tables(&ctx.db).await.unwrap();
386
387 let bakery = bakery::ActiveModel {
388 name: Set("SeaSide Bakery".to_owned()),
389 profit_margin: Set(10.4),
390 ..Default::default()
391 }
392 .insert(&ctx.db)
393 .await
394 .expect("could not insert bakery");
395
396 let customer_kate = customer::ActiveModel {
397 name: Set("Kate".to_owned()),
398 ..Default::default()
399 }
400 .insert(&ctx.db)
401 .await
402 .expect("could not insert customer");
403
404 let kate_order_1 = order::ActiveModel {
405 bakery_id: Set(bakery.id),
406 customer_id: Set(customer_kate.id),
407 total: Set(rust_dec(100.00)),
408 placed_at: Set(Utc::now().naive_utc()),
409
410 ..Default::default()
411 }
412 .insert(&ctx.db)
413 .await
414 .expect("could not insert order");
415
416 let _kate_order_2 = order::ActiveModel {
417 bakery_id: Set(bakery.id),
418 customer_id: Set(customer_kate.id),
419 total: Set(rust_dec(12.00)),
420 placed_at: Set(Utc::now().naive_utc()),
421
422 ..Default::default()
423 }
424 .insert(&ctx.db)
425 .await
426 .expect("could not insert order");
427
428 let customer_bob = customer::ActiveModel {
429 name: Set("Bob".to_owned()),
430 ..Default::default()
431 }
432 .insert(&ctx.db)
433 .await
434 .expect("could not insert customer");
435
436 let _bob_order_1 = order::ActiveModel {
437 bakery_id: Set(bakery.id),
438 customer_id: Set(customer_bob.id),
439 total: Set(rust_dec(50.0)),

Callers

nothing calls this directly

Calls 13

rust_decFunction · 0.85
unwrapMethod · 0.80
havingMethod · 0.80
group_byMethod · 0.80
column_asMethod · 0.80
columnMethod · 0.80
select_onlyMethod · 0.80
inner_joinMethod · 0.80
newFunction · 0.50
create_tablesFunction · 0.50
insertMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected