Report how many changes were done in the interface

This commit is contained in:
Bart Broere committed 2026-11-04 19:50:19 +01:00
1 parent dc978fd0fd
commit 8258bdc2a3
6 files changed
+140 -23

No files matched your search

+36 -1
View File
@@ -137,13 +137,48 @@ MATCH ()-[]->() RETURN { name:'relationships', data: count(*)} AS result
check("managed write transaction", s.execute_write(work) == 1)
def counts(tx):
first = tx.run("CREATE (:Temp {n: 4})").consume().counters
second = tx.run("MATCH (n:Temp {n: 4}) SET n.m = 1").consume().counters
return first, second
first, second = s.execute_write(counts)
check("each query in a transaction reports its own counts",
first.nodes_created == 1 and first.properties_set == 0
and second.nodes_created == 0 and second.properties_set == 1)
def read_your_writes(tx):
tx.run("CREATE (:Temp {n: 3}) RETURN 1")
return tx.run("UNWIND range(1, 1500) AS i MATCH (n:Temp {n: 3}) RETURN i").value()
check("query sees an earlier write in its transaction", len(s.execute_write(read_your_writes)) == 1500)
with driver.session(database=GRAPH) as s:
c = s.run("CREATE (a:Counted {i: 1})-[:LINK {w: 1}]->(b:Counted {i: 2})").consume().counters
check("CREATE counts", c.nodes_created == 2 and c.relationships_created == 1 and c.labels_added == 2
and c.contains_updates)
c = s.run("CREATE ({marker: 1})").consume().counters
check("a node without a label adds no label", c.nodes_created == 1 and c.labels_added == 0)
c = s.run("MATCH (n {marker: 1}) DELETE n").consume().counters
check("DELETE counts", c.nodes_deleted == 1)
summary = s.run("MATCH (n:Counted) SET n.j = 1, n.k = 2 RETURN n.j").consume()
check("SET counts changed nodes", summary.counters.properties_set == 2 and summary.query_type == "rw")
check("REMOVE counts", s.run("MATCH (n:Counted) REMOVE n.j").consume().counters.properties_set == 2)
check("MATCH of nothing with SET changes nothing",
not s.run("MATCH (n:Nothing) SET n.j = 1").consume().counters.contains_updates)
c = s.run("MERGE (n:Counted {i: 1})").consume().counters
check("MERGE that matches changes nothing", not c.contains_updates)
c = s.run("MERGE (n:Counted {i: 3})").consume().counters
check("MERGE that creates", c.nodes_created == 1)
summary = s.run("CREATE (:Counted {i: 4})").consume()
check("query without RETURN is a write", summary.query_type == "w")
c = s.run("MATCH (n:Counted) DETACH DELETE n").consume().counters
check("DETACH DELETE counts", c.nodes_deleted == 4 and c.relationships_deleted == 1)
summary = s.run("MATCH (n) RETURN count(n) AS c").consume()
check("a read changes nothing", not summary.counters.contains_updates and summary.query_type == "r")
with driver.session(database="system") as s:
s.run(f"DROP DATABASE {GRAPH}").consume()
c = s.run(f"DROP DATABASE {GRAPH}").consume().counters
check("system updates", c.system_updates == 1 and c.contains_system_updates)
sys.exit(1 if check.failed else 0)