File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,17 @@ mod implementation {
123123 }
124124 }
125125
126+ impl < C , B > AsyncConnectionWrapper < C , B >
127+ where
128+ C : crate :: AsyncConnection ,
129+ {
130+ /// Consumes the [`AsyncConnectionWrapper`] returning the wrapped inner
131+ /// [`AsyncConnection`].
132+ pub fn into_inner ( self ) -> C {
133+ self . inner
134+ }
135+ }
136+
126137 impl < C , B > Deref for AsyncConnectionWrapper < C , B > {
127138 type Target = C ;
128139
Original file line number Diff line number Diff line change @@ -66,3 +66,30 @@ fn check_run_migration() {
6666 // just use `run_migrations` here because that's the easiest one without additional setup
6767 conn. run_migrations ( & migrations) . unwrap ( ) ;
6868}
69+
70+ #[ tokio:: test]
71+ async fn test_sync_wrapper_unwrap ( ) {
72+ let db_url = std:: env:: var ( "DATABASE_URL" ) . unwrap ( ) ;
73+
74+ let conn = tokio:: task:: spawn_blocking ( move || {
75+ use diesel:: RunQueryDsl ;
76+
77+ let mut conn = AsyncConnectionWrapper :: < crate :: TestConnection > :: establish ( & db_url) . unwrap ( ) ;
78+ let res =
79+ diesel:: select ( 1 . into_sql :: < diesel:: sql_types:: Integer > ( ) ) . get_result :: < i32 > ( & mut conn) ;
80+ assert_eq ! ( Ok ( 1 ) , res) ;
81+ conn
82+ } )
83+ . await
84+ . unwrap ( ) ;
85+
86+ {
87+ use diesel_async:: RunQueryDsl ;
88+
89+ let mut conn = conn. into_inner ( ) ;
90+ let res = diesel:: select ( 1 . into_sql :: < diesel:: sql_types:: Integer > ( ) )
91+ . get_result :: < i32 > ( & mut conn)
92+ . await ;
93+ assert_eq ! ( Ok ( 1 ) , res) ;
94+ }
95+ }
You can’t perform that action at this time.
0 commit comments