Skip to content

Commit f99b797

Browse files
committed
refactor(database):重命名连接定制器结构体
- 将 ConnectionCreator 重命名为 ConnectionCustomizer
1 parent b914210 commit f99b797

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

file_classification_webapi/src/bin/utils/database.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ pub type DbPool = Pool<ConnectionManager<AnyConnection>>;
99
// 定义池化连接类型
1010
pub type DbPooledConnection = PooledConnection<ConnectionManager<AnyConnection>>;
1111

12-
/// 自定义连接创建器,用于在创建连接后执行 PRAGMA 命令
12+
/// 自定义连接定制器,用于在获取连接后执行 PRAGMA 命令
1313
#[derive(Debug)]
14-
struct ConnectionCreator;
14+
struct ConnectionCustomizer;
1515

16-
impl diesel::r2d2::CustomizeConnection<AnyConnection, diesel::r2d2::Error> for ConnectionCreator {
16+
impl diesel::r2d2::CustomizeConnection<AnyConnection, diesel::r2d2::Error> for ConnectionCustomizer {
1717
fn on_acquire(&self, conn: &mut AnyConnection) -> Result<(), diesel::r2d2::Error> {
18-
// 只有 SQLite 连接才这样关闭外键约束
1918
match conn {
19+
// 只有 SQLite 连接才使用以下语句关闭外键约束
2020
AnyConnection::Sqlite(_) => {
2121
// 关闭外键约束检查
2222
diesel::sql_query("PRAGMA foreign_keys = OFF")
@@ -44,7 +44,7 @@ pub fn establish_connection_pool() -> DbPool {
4444
};
4545

4646
Pool::builder()
47-
.connection_customizer(Box::new(ConnectionCreator))
47+
.connection_customizer(Box::new(ConnectionCustomizer))
4848
.build(manager)
4949
.expect("Failed to create pool.")
5050
}

0 commit comments

Comments
 (0)