File tree Expand file tree Collapse file tree
file_classification_core/src/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,27 +27,27 @@ pub fn insert_file(
2727 match conn {
2828 #[ cfg( feature = "sqlite" ) ]
2929 // 对于 SQLite 连接,使用 returning 子句
30- AnyConnection :: Sqlite ( _ ) => {
31- diesel:: insert_into ( files:: table) . values ( new_file) . returning ( files:: id) . get_result ( conn )
30+ AnyConnection :: Sqlite ( sqlite ) => {
31+ diesel:: insert_into ( files:: table) . values ( new_file) . returning ( files:: id) . get_result ( sqlite )
3232 }
3333 #[ cfg( feature = "mysql" ) ]
3434 // 对于 MySQL 连接,使用事务方式
35- AnyConnection :: Mysql ( _ ) => {
36- conn. transaction ( |conn | {
35+ AnyConnection :: Mysql ( mysql ) => {
36+ conn. transaction ( |mysql | {
3737 // 执行插入操作
3838 diesel:: insert_into ( files:: table)
3939 . values ( new_file)
40- . execute ( conn ) ?;
40+ . execute ( mysql ) ?;
4141
4242 // MySQL使用LAST_INSERT_ID()获取最后插入的ID
4343 let last_id: i32 = diesel:: select ( diesel:: dsl:: sql :: < diesel:: sql_types:: Integer > ( "LAST_INSERT_ID()" ) )
44- . get_result ( conn ) ?;
44+ . get_result ( mysql ) ?;
4545
4646 Ok ( last_id)
4747 } )
4848 } ,
4949 // 默认情况(如其他数据库类型)使用 returning 子句
50- _ => diesel:: insert_into ( files:: table) . values ( new_file) . returning ( files:: id) . get_result ( conn ) ,
50+ other_database_type => diesel:: insert_into ( files:: table) . values ( new_file) . returning ( files:: id) . get_result ( other_database_type ) ,
5151 }
5252}
5353
Original file line number Diff line number Diff line change @@ -28,28 +28,28 @@ pub fn insert_group(
2828 match conn {
2929 #[ cfg( feature = "sqlite" ) ]
3030 // 对于 SQLite 连接,使用 returning 子句
31- AnyConnection :: Sqlite ( _ ) => {
32- diesel:: insert_into ( groups:: table) . values ( new_group) . returning ( groups:: id) . get_result ( conn )
31+ AnyConnection :: Sqlite ( sqlite ) => {
32+ diesel:: insert_into ( groups:: table) . values ( new_group) . returning ( groups:: id) . get_result ( sqlite )
3333 }
3434 #[ cfg( feature = "mysql" ) ]
3535 // 对于 MySQL 连接,使用事务方式
36- AnyConnection :: Mysql ( _ ) => {
37- conn . transaction ( |conn | {
36+ AnyConnection :: Mysql ( mysql ) => {
37+ mysql . transaction ( |mysql | {
3838 // 执行插入操作
3939 diesel:: insert_into ( groups:: table)
4040 . values ( new_group)
41- . execute ( conn ) ?;
41+ . execute ( mysql ) ?;
4242
4343 // MySQL使用LAST_INSERT_ID()获取最后插入的ID
4444 let last_id: i32 = diesel:: select ( diesel:: dsl:: sql :: < diesel:: sql_types:: Integer > ( "LAST_INSERT_ID()" ) )
45- . get_result ( conn ) ?;
45+ . get_result ( mysql ) ?;
4646
4747 Ok ( last_id)
4848 } )
4949 } ,
5050 // 默认情况(如其他数据库类型)使用 returning 子句
51- _ => {
52- diesel:: insert_into ( groups:: table) . values ( new_group) . returning ( groups:: id) . get_result ( conn )
51+ other_database_type => {
52+ diesel:: insert_into ( groups:: table) . values ( new_group) . returning ( groups:: id) . get_result ( other_database_type )
5353 }
5454 }
5555}
Original file line number Diff line number Diff line change @@ -27,27 +27,27 @@ pub fn insert_tag(
2727 match conn {
2828 #[ cfg( feature = "sqlite" ) ]
2929 // 对于 SQLite 连接,使用 returning 子句
30- AnyConnection :: Sqlite ( _ ) => {
31- diesel:: insert_into ( tags:: table) . values ( new_tag) . returning ( tags:: id) . get_result ( conn )
30+ AnyConnection :: Sqlite ( sqlite ) => {
31+ diesel:: insert_into ( tags:: table) . values ( new_tag) . returning ( tags:: id) . get_result ( sqlite )
3232 }
3333 #[ cfg( feature = "mysql" ) ]
3434 // 对于 MySQL 连接,使用事务方式(暂时注释掉,因为目前没有启用mysql,注意不要删除以下注释内容,将来会用到)
35- AnyConnection :: Mysql ( _ ) => {
36- conn . transaction ( |conn | {
35+ AnyConnection :: Mysql ( mysql ) => {
36+ mysql . transaction ( |mysql | {
3737 // 执行插入操作
3838 diesel:: insert_into ( tags:: table)
3939 . values ( new_tag)
40- . execute ( conn ) ?;
40+ . execute ( mysql ) ?;
4141
4242 // MySQL使用LAST_INSERT_ID()获取最后插入的ID
4343 let last_id: i32 = diesel:: select ( diesel:: dsl:: sql :: < diesel:: sql_types:: Integer > ( "LAST_INSERT_ID()" ) )
44- . get_result ( conn ) ?;
44+ . get_result ( mysql ) ?;
4545
4646 Ok ( last_id)
4747 } )
4848 } ,
4949 // 默认情况(如其他数据库类型)使用 returning 子句
50- _ => diesel:: insert_into ( tags:: table) . values ( new_tag) . returning ( tags:: id) . get_result ( conn ) ,
50+ other_database_type => diesel:: insert_into ( tags:: table) . values ( new_tag) . returning ( tags:: id) . get_result ( other_database_type ) ,
5151 }
5252}
5353
You can’t perform that action at this time.
0 commit comments