@@ -12,7 +12,10 @@ use std::string::ToString;
1212pub trait AsyncTransaction {
1313 type Error : std:: error:: Error + Send + Sync + ' static ;
1414
15- async fn execute ( & mut self , query : & [ & str ] ) -> Result < usize , Self :: Error > ;
15+ async fn execute < ' a , T : Iterator < Item = & ' a str > + Send > (
16+ & mut self ,
17+ queries : T ,
18+ ) -> Result < usize , Self :: Error > ;
1619}
1720
1821#[ async_trait]
@@ -43,10 +46,13 @@ async fn migrate<T: AsyncTransaction>(
4346 migration. set_applied ( ) ;
4447 let update_query = insert_migration_query ( & migration, migration_table_name) ;
4548 transaction
46- . execute ( & [
47- migration. sql ( ) . as_ref ( ) . expect ( "sql must be Some!" ) ,
48- & update_query,
49- ] )
49+ . execute (
50+ [
51+ migration. sql ( ) . as_ref ( ) . expect ( "sql must be Some!" ) ,
52+ update_query. as_str ( ) ,
53+ ]
54+ . into_iter ( ) ,
55+ )
5056 . await
5157 . migration_err (
5258 & format ! ( "error applying migration {migration}" ) ,
@@ -109,10 +115,8 @@ async fn migrate_grouped<T: AsyncTransaction>(
109115 ) ;
110116 }
111117
112- let refs: Vec < & str > = grouped_migrations. iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
113-
114118 transaction
115- . execute ( refs . as_ref ( ) )
119+ . execute ( grouped_migrations . iter ( ) . map ( AsRef :: as_ref ) )
116120 . await
117121 . migration_err ( "error applying migrations" , None ) ?;
118122
@@ -142,7 +146,7 @@ where
142146 migration_table_name : & str ,
143147 ) -> Result < Option < Migration > , Error > {
144148 let mut migrations = self
145- . query ( Self :: get_last_applied_migration_query ( migration_table_name) . as_str ( ) )
149+ . query ( Self :: get_last_applied_migration_query ( migration_table_name) . as_ref ( ) )
146150 . await
147151 . migration_err ( "error getting last applied migration" , None ) ?;
148152
@@ -154,7 +158,7 @@ where
154158 migration_table_name : & str ,
155159 ) -> Result < Vec < Migration > , Error > {
156160 let migrations = self
157- . query ( Self :: get_applied_migrations_query ( migration_table_name) . as_str ( ) )
161+ . query ( Self :: get_applied_migrations_query ( migration_table_name) . as_ref ( ) )
158162 . await
159163 . migration_err ( "error getting applied migrations" , None ) ?;
160164
@@ -170,9 +174,11 @@ where
170174 target : Target ,
171175 migration_table_name : & str ,
172176 ) -> Result < Report , Error > {
173- self . execute ( & [ & Self :: assert_migrations_table_query ( migration_table_name) ] )
174- . await
175- . migration_err ( "error asserting migrations table" , None ) ?;
177+ self . execute (
178+ [ Self :: assert_migrations_table_query ( migration_table_name) . as_ref ( ) ] . into_iter ( ) ,
179+ )
180+ . await
181+ . migration_err ( "error asserting migrations table" , None ) ?;
176182
177183 let applied_migrations = self
178184 . get_applied_migrations ( migration_table_name)
0 commit comments