Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using a transaction #135

Open
OrangeBoreal opened this issue Mar 2, 2017 · 2 comments
Open

Error when using a transaction #135

OrangeBoreal opened this issue Mar 2, 2017 · 2 comments

Comments

@OrangeBoreal
Copy link

When committing or rolling back from a transaction, subsequent calls to the client result in a TransactionException :

from neo4jrestclient import client
import os
c = client.GraphDatabase(url=os.environ["NEO4J_URL"])
res = c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n") assert res.get_response()["data"][0][0]["data"] == {"name": "Carol"}

with c.transaction(for_query=True) as t:
    c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")
    t.rollback()  # or commit()

c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")
TransactionException                      Traceback (most recent call last)
<ipython-input-16-c750d86ca4cf> in <module>()
      9     t.commit()
     10 
---> 11 c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")

.../code/neo4j-rest-client/neo4jrestclient/client.pyc in query(self, q, params, returns, data_contents, tx)
    210                 self._cypher, self._auth, q=q, params=params,
    211                 types=types, returns=returns, data_contents=data_contents,
--> 212                 tx=tx
    213             )
    214             if tx is not None and tx.id in self._transactions:

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in __init__(self, cypher, auth, q, params, types, returns, lazy, data_contents, tx)
    322             tx.append(q=self.q, params=self.params, returns=self._returns,
    323                       data_contents=data_contents, obj=self)
--> 324             tx.execute()
    325         elif not lazy:
    326             self._get_elements()

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in execute(self)
    937         if not self.url_tx:
    938             self._begin()
--> 939         results = self._execute(self.url_tx, results=True)
    940         self.finished = False
    941         return results

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in _execute(self, url, results)
    863 
    864     def _execute(self, url, results=True):
--> 865         response = self._request(url, statements=self.statements)
    866         content = response.json()
    867         self._manage_errors(content["errors"])

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in _request(self, url, statements)
    860             return response
    861         else:
--> 862             raise TransactionException(response.status_code)
    863 
    864     def _execute(self, url, results=True):

TransactionException: Code [404]: Not Found. Nothing matches the given URI.
Element not found

The client is completely block unless calling .flush()

@versae
Copy link
Owner

versae commented Mar 20, 2017

Sorry for the late reply. After rolling back the transaction gets destroyed, thus the 404. But then it should not try to execute any query. It seems like the local transaction is not destroyed. Have you tried not using the with statement?

@OrangeBoreal
Copy link
Author

I've got the same issue, whether I'm using the context manager or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants