Skip to content

Commit 3bb4fbc

Browse files
committed
continue implementing transaction
1 parent dc960e4 commit 3bb4fbc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/driver/transaction.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,18 +1267,30 @@ impl Transaction {
12671267
}
12681268

12691269
async fn __aenter__<'a>(slf: Py<Self>) -> RustPSQLDriverPyResult<Py<Self>> {
1270-
let (is_transaction_ready, isolation_level, read_variant, deferrable, db_client) =
1270+
let (is_started, is_done, isolation_level, read_variant, deferrable, db_client) =
12711271
pyo3::Python::with_gil(|gil| {
12721272
let self_ = slf.borrow(gil);
12731273
(
1274-
self_.check_is_transaction_ready(),
1274+
self_.is_started,
1275+
self_.is_done,
12751276
self_.isolation_level,
12761277
self_.read_variant,
12771278
self_.deferrable,
12781279
self_.db_client.clone(),
12791280
)
12801281
});
1281-
is_transaction_ready?;
1282+
1283+
if is_started {
1284+
return Err(RustPSQLDriverError::DataBaseTransactionError(
1285+
"Transaction is already started".into(),
1286+
));
1287+
}
1288+
1289+
if is_done {
1290+
return Err(RustPSQLDriverError::DataBaseTransactionError(
1291+
"Transaction is already committed or rolled back".into(),
1292+
));
1293+
}
12821294
db_client
12831295
.start_transaction(isolation_level, read_variant, deferrable)
12841296
.await?;

0 commit comments

Comments
 (0)