Skip to content

Commit a1f74b4

Browse files
committed
Fix Neo4j queries and setup logic.
1 parent 01b2970 commit a1f74b4

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/ops/storages/neo4j.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ CALL {{
275275
DELETE old_tgt
276276
RETURN 0 AS _2
277277
}}
278+
279+
FINISH
278280
"#,
279281
rel_type = spec.relationship,
280282
rel_key_field_name = key_field.name,
@@ -289,14 +291,25 @@ CALL {{
289291
r#"
290292
MERGE (new_src:{src_node_label} {{{src_node_key_field_name}: ${SRC_ID_PARAM}}})
291293
MERGE (new_tgt:{tgt_node_label} {{{tgt_node_key_field_name}: ${TGT_ID_PARAM}}})
292-
MERGE (new_src)-[new_rel:{rel_type} {{id: ${REL_ID_PARAM}}}]->(new_tgt)
294+
MERGE (new_src)-[new_rel:{rel_type} {{{rel_key_field_name}: ${REL_ID_PARAM}}}]->(new_tgt)
293295
{optional_set_rel_props}
296+
297+
FINISH
294298
"#,
295299
src_node_label = spec.source.label,
296-
src_node_key_field_name = spec.source.field_name,
300+
src_node_key_field_name = spec
301+
.nodes
302+
.get(&spec.source.label)
303+
.and_then(|node| node.key_field_name.as_ref().map(|n| n.as_str()))
304+
.unwrap_or_else(|| DEFAULT_KEY_FIELD_NAME),
297305
tgt_node_label = spec.target.label,
298-
tgt_node_key_field_name = spec.target.field_name,
306+
tgt_node_key_field_name = spec
307+
.nodes
308+
.get(&spec.target.label)
309+
.and_then(|node| node.key_field_name.as_ref().map(|n| n.as_str()))
310+
.unwrap_or_else(|| DEFAULT_KEY_FIELD_NAME),
299311
rel_type = spec.relationship,
312+
rel_key_field_name = key_field.name,
300313
);
301314
Self {
302315
graph,
@@ -358,6 +371,7 @@ impl ExportTargetExecutor for RelationshipStorageExecutor {
358371

359372
let mut txn = self.graph.start_txn().await?;
360373
txn.run_queries(queries).await?;
374+
txn.commit().await?;
361375
Ok(())
362376
}
363377
}
@@ -479,11 +493,7 @@ impl SetupStatusCheck {
479493
})
480494
.map(|existing_current| DataClearAction {
481495
rel_type: key.relationship.clone(),
482-
node_labels: existing_current
483-
.nodes
484-
.values()
485-
.map(|node| node.key_constraint_name.clone())
486-
.collect(),
496+
node_labels: existing_current.nodes.keys().cloned().collect(),
487497
});
488498

489499
let mut old_rel_constraints = IndexSet::new();
@@ -572,7 +582,7 @@ impl ResourceSetupStatusCheck for SetupStatusCheck {
572582
let mut result = vec![];
573583
if let Some(data_clear) = &self.data_clear {
574584
result.push(format!(
575-
"Clear data for relationship {}; nodes {})",
585+
"Clear data for relationship {}; nodes {}",
576586
data_clear.rel_type,
577587
data_clear.node_labels.iter().join(", "),
578588
));

0 commit comments

Comments
 (0)