File tree Expand file tree Collapse file tree
file_classification_webapi/src/bin/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ pub type DbPool = Pool<ConnectionManager<AnyConnection>>;
99// 定义池化连接类型
1010pub 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}
You can’t perform that action at this time.
0 commit comments