Skip to content

querying arangodb view inside transaction #356

@konnerthg

Description

@konnerthg

I have an Arango collection called Documents and an arangosearch view called Documents_view. I am trying to query the view inside a transactional database:

collection = "Documents"
document = {
    "name": "foo",
}

txn_db = arango.db.begin_transaction(read=[collection], write=[collection])
txn_db.insert_document(
    collection=collection,
    document=document,
)

cursor = txn_db.aql.execute(
    query="""
        FOR o IN Documents_view
        RETURN {
           name: o.name,
        }
    """
)

print("documents in view:")
print(list(cursor))

cursor = txn_db.aql.execute(
    query="""
        FOR o IN Documents
        RETURN {
           name: o.name,
        }
    """
)

print("documents in collection:")
print(list(cursor))

txn_db.abort_transaction()

The output reads:

documents in view:
[]
documents in collection:
[{'name': 'foo'}]

It seems like the view does not function inside the transaction? I tried adding "Documents_view" to the list of the transaction's read collections as described here. But this results in an error: arango.exceptions.TransactionInitError: [HTTP 404][ERR 1203] collection or view not found

When printing the list of views: print(txn_db.views()), the Documents_view shows. So I am sure it exists. Even more oddly, when printing the full view: print(txn_db.view(name="Documents_view")), it correctly shows the inserted document: [{'name': 'foo'}]

Am I missing something? Is this behavior intended?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions