1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! v6.2 性能优化:SeaORM/SQLx 对标基准集成测试
//!
//! 验证对标基准可运行(不 panic)。
//! 标注 `#[ignore]` 因需 dev-dependency,用 `--ignored` 触发。
#[cfg(feature = "bench-seaorm")]
mod seaorm_tests {
/// 验证 SeaORM 查询构建可运行
#[tokio::test]
#[ignore]
async fn seaorm_query_build_runs() {
use sea_orm::query::Query;
use sea_orm::Expr;
let select = Query::select()
.from("users")
.and_where(Expr::col("id").eq(42))
.to_owned();
assert!(select.to_string().contains("users"));
}
}
mod sqlx_tests {
/// 验证 SQLx 查询构建可运行
#[tokio::test]
#[ignore]
async fn sqlx_query_build_runs() {
use sqlx::Sqlite;
let query = sqlx::query::<Sqlite>("SELECT * FROM users WHERE id = ?")
.bind(42i64);
let _ = query;
}
/// 验证 SQLx SQLite 内存池可创建
#[tokio::test]
#[ignore]
async fn sqlx_pool_create_runs() {
use sqlx::sqlite::SqlitePoolOptions;
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect("sqlite::memory:")
.await
.expect("pool");
pool.close().await;
}
}