MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_parameter_limit

Function test_parameter_limit

tests/protocol_edge_cases_test.rs:387–438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

385
386#[tokio::test]
387async fn test_parameter_limit() {
388 let server = setup_test_server_with_init(|db| {
389 Box::pin(async move {
390 // Create table with many columns
391 let mut cols = Vec::new();
392 for i in 1..=100 {
393 cols.push(format!("col{i} INTEGER"));
394 }
395
396 db.execute(&format!(
397 "CREATE TABLE many_params (id INTEGER PRIMARY KEY, {})",
398 cols.join(", ")
399 )).await?;
400
401 Ok(())
402 })
403 }).await;
404
405 let client = &server.client;
406
407 // Test with many parameters (PostgreSQL supports up to 65535 parameters)
408 // We'll test with 100 parameters
409 let mut params: Vec<i32> = Vec::new();
410 for i in 1..=101 {
411 params.push(i);
412 }
413
414 let mut placeholders = Vec::new();
415 let mut param_refs: Vec<&(dyn tokio_postgres::types::ToSql + Sync)> = Vec::new();
416
417 for (i, param) in params.iter().enumerate().take(101) {
418 placeholders.push(format!("${}", i + 1));
419 param_refs.push(param);
420 }
421
422 let query = format!(
423 "INSERT INTO many_params VALUES ({})",
424 placeholders.join(", ")
425 );
426
427 match client.execute(&query, &param_refs).await {
428 Ok(n) => {
429 assert_eq!(n, 1);
430 println!("Successfully inserted with 101 parameters");
431 }
432 Err(e) => {
433 println!("Failed with many parameters: {e}");
434 }
435 }
436
437 server.abort();
438}

Callers

nothing calls this directly

Calls 4

takeMethod · 0.80
abortMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected