typedb-driver icon indicating copy to clipboard operation
typedb-driver copied to clipboard

[Python] Transaction `is_open` method throws an exception if called after transaction is committed

Open james-whiteside opened this issue 5 months ago • 0 comments

Description

If the is_open method of a TypeDBTransaction is called after the transaction is committed, an exception is thrown instead of returning False. This is not the case if the transaction is instead closed, after which is_open functions as expected.

Environment

  1. TypeDB distribution: Core
  2. TypeDB version: 2.27.0
  3. Environment: MacOS

Reproducible Steps

with TypeDB.core_driver("localhost:1729") as driver:
    with driver.session("test", SessionType.DATA) as session:
        with session.transaction(TransactionType.WRITE) as transaction:
            print(f"Deleting existing data.")
            transaction.query.delete(query="match $x isa $t; delete $x isa $t;").resolve()
            transaction.commit()
            print(transaction.is_open())

Additional information

Traceback (most recent call last):
  File "...", line 51, in <module>
    print(transaction.is_open())
          ^^^^^^^^^^^^^^^^^^^^^
  File ".../typedb/connection/transaction.py", line 80, in is_open
    if not self.native_object.thisown:
           ^^^^^^^^^^^^^^^^^^
  File ".../typedb/common/native_wrapper.py", line 42, in native_object
    raise self._native_object_not_owned_exception
typedb.common.exception.TypeDBDriverException: Driver Error: The transaction has been closed and no further operation is allowed.

james-whiteside avatar Sep 24 '24 14:09 james-whiteside