File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -593,17 +593,24 @@ impl Transaction {
593593 slf : PyRefMut < ' a , Self > ,
594594 py : Python < ' a > ,
595595 _exception_type : Py < PyAny > ,
596- _exception : Py < PyAny > ,
596+ exception : & PyAny ,
597597 _traceback : Py < PyAny > ,
598598 ) -> RustPSQLDriverPyResult < & ' a PyAny > {
599599 let transaction_arc = slf. transaction . clone ( ) ;
600600 let transaction_arc2 = slf. transaction . clone ( ) ;
601+ let is_no_exc = exception. is_none ( ) ;
602+ let exc_message = format ! ( "{exception}" ) ;
601603 rustengine_future ( py, async move {
602604 let transaction_guard = transaction_arc. read ( ) . await ;
603- transaction_guard. inner_commit ( ) . await ?;
604- Ok ( Transaction {
605- transaction : transaction_arc2,
606- } )
605+ if is_no_exc {
606+ transaction_guard. inner_commit ( ) . await ?;
607+ Ok ( Transaction {
608+ transaction : transaction_arc2,
609+ } )
610+ } else {
611+ transaction_guard. inner_rollback ( ) . await ?;
612+ Err ( RustPSQLDriverError :: DataBaseTransactionError ( exc_message) )
613+ }
607614 } )
608615 }
609616
You can’t perform that action at this time.
0 commit comments