Skip to content

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

Open
@james-whiteside

Description

@james-whiteside

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions