summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/neo4j/reset-db__single_link.cypher6
-rw-r--r--src/server/db_op.py10
2 files changed, 12 insertions, 4 deletions
diff --git a/res/neo4j/reset-db__single_link.cypher b/res/neo4j/reset-db__single_link.cypher
index 72242ee1..194d015e 100644
--- a/res/neo4j/reset-db__single_link.cypher
+++ b/res/neo4j/reset-db__single_link.cypher
@@ -1,5 +1,5 @@
// Flush
-match (n) optional match (n)-[r]-() delete n,r;
+match (n) optional match (n)-[r]-() delete r,n;
//
// Constraints
@@ -9,8 +9,10 @@ match (n) optional match (n)-[r]-() delete n,r;
create constraint on (x:Person) assert x.name is unique;
create constraint on (x:Skill) assert x.name is unique;
+// init commit block chain
+create (n:__HEAD:__Commit {hash: 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc', blob: ''}) create (n)-[:__Parent]->(n);
+
// Data
-create (n:HEAD:Commit {hash: 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc', blob: ''});
create (x:Person {name:'Bob', id: 'p_0', description: 'Bob is ...' });
create (x:Skill {name:'Kung-Fu', id: 's_0', description: 'Kung-Fu is ...'});
match (m:Person {id: 'p_0'}),(n:Skill {id: 's_0'}) create (m)-[:Knows {id: 'l_0'}]->(n);
diff --git a/src/server/db_op.py b/src/server/db_op.py
index fa5e8ed9..4ab4390e 100644
--- a/src/server/db_op.py
+++ b/src/server/db_op.py
@@ -107,6 +107,12 @@ class DB_composed_op(DB_op):
return ret
class DBO_chain_commit_block(DB_op):
+ """
+ Labels in use:
+ - __HEAD: HEAD commit, unique
+ - __Parent: parent commit relationship
+ - __Commit: node type
+ """
@staticmethod
def calc_blob_hash(blob):
@@ -128,8 +134,8 @@ class DBO_chain_commit_block(DB_op):
hash_value = DBO_chain_commit_block.calc_blob_hash(blob_obj)
q_arr = ["match (old_head:__HEAD:__Commit)",
"create (new_head:__HEAD:__Commit {hash: {hash_value}, blob: {blob_value}})",
- "create new_head-[l:__Parent]->old_head",
- "remove old_head:HEAD",
+ "create new_head-[r:__Parent]->old_head",
+ "remove old_head:__HEAD",
"return old_head, new_head"]
q = " ".join(q_arr)