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

Function exists_with_limit_offset

tests/exists_tests.rs:230–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228
229#[sea_orm_macros::test]
230pub async fn exists_with_limit_offset() {
231 let ctx = TestContext::new("exists_with_limit_offset").await;
232 create_tables(&ctx.db).await.unwrap();
233
234 // Insert multiple bakeries
235 for i in 1..=5 {
236 let _bakery = bakery::ActiveModel {
237 name: Set(format!("Bakery {}", i)),
238 profit_margin: Set(10.0 + (i as f64)),
239 ..Default::default()
240 }
241 .save(&ctx.db)
242 .await
243 .expect("could not insert bakery");
244 }
245
246 // Test exists with limit - should still find records
247 let exists = Bakery::find().limit(2).exists(&ctx.db).await.unwrap();
248 assert_eq!(exists, true);
249
250 // Test exists with offset - should still find records
251 let exists = Bakery::find().offset(3).exists(&ctx.db).await.unwrap();
252 assert_eq!(exists, true);
253
254 // Test exists with limit and offset - exists() checks for existence regardless of offset
255 // This is the expected behavior since exists() is optimized to check if ANY record exists
256 let exists = Bakery::find()
257 .offset(10) // Beyond all records
258 .limit(1)
259 .exists(&ctx.db)
260 .await
261 .unwrap();
262 assert_eq!(exists, true); // exists() ignores offset for performance optimization
263
264 ctx.delete().await;
265}

Callers

nothing calls this directly

Calls 8

unwrapMethod · 0.80
saveMethod · 0.80
limitMethod · 0.80
offsetMethod · 0.80
newFunction · 0.50
create_tablesFunction · 0.50
existsMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected