arangodb/python-arango

Edges not retrievable without committing transaction

james10424 opened this issue · 2 comments

Transaction works with documents, but not edges.

Platform info:

  • os: MacOS 12.6
  • Arango: 3.10.2
  • python-arango: 7.5.5
  • python: 3.10.0

Sample code to reproduce:

def test_transaction():
    client = ArangoClient()
    sys_db = client.db(
        "_system", username="username", password="password"
    )
    # drop and recreate the test db
    sys_db.delete_database("test", ignore_missing=True)
    sys_db.create_database("test")
    db = client.db(
        "test", username="username", password="password"
    )
    # create stuff
    graph = db.create_graph("graph")
    graph.create_vertex_collection("a")
    graph.create_vertex_collection("b")
    edge = graph.create_edge_definition(
        edge_collection="edge",
        from_vertex_collections=["a"],
        to_vertex_collections=["b"],
    )

    tx = db.begin_transaction(
        read=["a", "b", "edge"],
        write=["a", "b", "edge"],
    )
    graph = tx.graph("graph")
    # does not work with regular collection either
    a = graph.vertex_collection("a")
    b = graph.vertex_collection("b")
    a_doc = a.insert({})
    b_doc = b.insert({})
    # verify that they are retrievable without committing
    assert a.get(a_doc["_key"]) is not None
    assert b.get(b_doc["_key"]) is not None
    edge = graph.edge_collection("edge")
    # link a and b
    edge.link(a_doc["_id"], b_doc["_id"])
    edges = edge.edges(a_doc["_id"])
    # this fails without committing
    # tx.commit_transaction()
    assert len(edges["edges"]) == 1
    tx.abort_transaction()

Hey @james10424

Seems that EdgeCollection.edges() (GET /_api/edges/<name>) does not behave the same way as EdgeCollection.get() (GET /_api/gharial/<graph name>/edge/<id>) in terms of transactions.

I can suggest the following for now:

new_edge = edge.link(a_doc["_id"], b_doc["_id"])
assert edge.get(new_edge["_key"]) is not None
# edges = edge.edges(a_doc["_id"])
# assert len(edges["edges"]) == 1

Hey @james10424,

Did the fix suggested by @aMahanna work for you? Are you still experiencing issues?

Since the functionality is already there, I would tend to close this as "Not Planned"