Closed mehmetbilgin closed 9 years ago
Hello @mehmetbilgin ,
Thanks for using the library.
The second query will not fail, simply because Neo4j will not return you an error and the transaction will be ok.
If you try the same query in the neo4j browser you can see just that the query will return a 200 result and just return you no data (in fact there are no schema violations, syntax errors or anything else that can make fail the query) It is how Cypher behaves, if he matches nothing he will just not execute the creates.
So yes, sendCypherQuery will behave the same in the two cases.
If you need to be sure that the query has executed changes to the graph, you may in this case like you said return the username or one of the book titles.
Got it thanks.
Hi Christophe, thanks for this library and keeping it up-to date with recent Neo4j updates.
I have one question regarding create queries. What is the best method to check whether query is successful or not. For example if there is an user with username=mehmet, first query will be successful but the second one will fail.
MATCH (user:User {username:'mehmet' }) CREATE (book:Book { title:'hobbit' }) CREATE (user)-[:READ]->(book)
MATCH (user:User {username:'invalid' }) CREATE (book:Book { title:'hobbit' }) CREATE (user)-[:READ]->(book)
When I check the sendCypherQuery() response I can't see any difference for these queries.
Of course I can add a return clause like "RETURN book.title" to the query and check its existence in the response to check result but I wanted to check whether is there a better method.