File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ pub use self::run_query_dsl::*;
20
20
pub use self :: stmt_cache:: StmtCache ;
21
21
pub use self :: transaction_manager:: { AnsiTransactionManager , TransactionManager } ;
22
22
23
-
24
23
#[ async_trait:: async_trait]
25
24
pub trait SimpleAsyncConnection {
26
25
async fn batch_execute ( & mut self , query : & str ) -> QueryResult < ( ) > ;
Original file line number Diff line number Diff line change @@ -146,7 +146,8 @@ impl AsyncMysqlConnection {
146
146
] ;
147
147
148
148
for stmt in setup_statements {
149
- diesel:: sql_query ( stmt) . execute ( & mut conn)
149
+ diesel:: sql_query ( stmt)
150
+ . execute ( & mut conn)
150
151
. await
151
152
. map_err ( ConnectionError :: CouldntSetupConfiguration ) ?;
152
153
}
Original file line number Diff line number Diff line change @@ -207,8 +207,12 @@ impl AsyncPgConnection {
207
207
async fn set_config_options ( & mut self ) -> QueryResult < ( ) > {
208
208
use crate :: run_query_dsl:: RunQueryDsl ;
209
209
210
- diesel:: sql_query ( "SET TIME ZONE 'UTC'" ) . execute ( self ) . await ?;
211
- diesel:: sql_query ( "SET CLIENT_ENCODING TO 'UTF8'" ) . execute ( self ) . await ?;
210
+ diesel:: sql_query ( "SET TIME ZONE 'UTC'" )
211
+ . execute ( self )
212
+ . await ?;
213
+ diesel:: sql_query ( "SET CLIENT_ENCODING TO 'UTF8'" )
214
+ . execute ( self )
215
+ . await ?;
212
216
Ok ( ( ) )
213
217
}
214
218
@@ -232,9 +236,7 @@ impl AsyncPgConnection {
232
236
let res = query. collect_binds ( & mut bind_collector, self , & diesel:: pg:: Pg ) ;
233
237
234
238
if !self . next_lookup . is_empty ( ) {
235
- for ( schema, lookup_type_name) in
236
- std:: mem:: take ( & mut self . next_lookup )
237
- {
239
+ for ( schema, lookup_type_name) in std:: mem:: take ( & mut self . next_lookup ) {
238
240
// as this is an async call and we don't want to infect the whole diesel serialization
239
241
// api with async we just error out in the `PgMetadataLookup` implementation below if we encounter
240
242
// a type that is not cached yet
Original file line number Diff line number Diff line change @@ -77,9 +77,36 @@ async fn test_basic_insert_and_load() -> QueryResult<()> {
77
77
Ok ( ( ) )
78
78
}
79
79
80
+ #[ cfg( feature = "mysql" ) ]
81
+ async fn setup ( connection : & mut TestConnection ) -> TestConnection {
82
+ diesel:: sql_query (
83
+ "CREATE TABLE IF NOT EXISTS users (
84
+ id INTEGER PRIMARY KEY AUTO_INCREMENT,
85
+ name TEXT NOT NULL
86
+ ) CHARACTER SET utf8mb4" ,
87
+ )
88
+ . execute ( & mut connection)
89
+ . await
90
+ . unwrap ( ) ;
91
+ }
92
+
93
+ #[ cfg( feature = "postgres" ) ]
94
+ async fn setup ( connection : & mut TestConnection ) -> TestConnection {
95
+ diesel:: sql_query (
96
+ "CREATE TABLE IF NOT EXISTS users (
97
+ id SERIAL PRIMARY KEY,
98
+ name VARCHAR NOT NULL
99
+ )" ,
100
+ )
101
+ . execute ( & mut connection)
102
+ . await
103
+ . unwrap ( ) ;
104
+ }
105
+
80
106
async fn connection ( ) -> TestConnection {
81
107
let db_url = std:: env:: var ( "DATABASE_URL" ) . unwrap ( ) ;
82
108
let mut conn = TestConnection :: establish ( & db_url) . await . unwrap ( ) ;
83
109
conn. begin_test_transaction ( ) . await . unwrap ( ) ;
110
+ setup ( & mut conn) ;
84
111
conn
85
112
}
You can’t perform that action at this time.
0 commit comments