I'm trying to introduce a transaction using py2neo. At the beginning of the code to be transactional I open new transaction using:
tx = graph.cypher.begin()
after that there are several actions taken:
- Read some data already stored in the database before transaction has started
- Create new node based on that
- Create another node
- Create the relationship between those two nodes
- Read that relationship using node.match_outgoing(relation_type)
While actions 1-4 are done correctly, the last one fails on "node not bound". This is no suprise as transaction haven't been commited yet and there is no remote counterpart for that node. Still, I need to do it like this. The other approach would require a huge refactoring and a spaghetti code.
For creating nodes in transaction I'm using CreateStatement from cypher.It's done like that:
graph = db_connection.get_graph()
statement = CreateStatement(graph)
statement.create(relation)
append_to_current_tx(statement)
So there is no way of getting the node that is in bound-like state (a transient one).
Is there a way to read relationships for the node that was just created in a transaction that is still uncommited (but all of it's relationships are created before in the same transaction). Are there nested transactions in py2neo?