diff --git a/pkg/neo4j/save-event.go b/pkg/neo4j/save-event.go index 4ab9f35..80887b9 100644 --- a/pkg/neo4j/save-event.go +++ b/pkg/neo4j/save-event.go @@ -134,6 +134,10 @@ CREATE (e)-[:AUTHORED_BY]->(a) eTagIndex := 0 pTagIndex := 0 + // Track if we need to add WITH clause before OPTIONAL MATCH + // This is required because Cypher doesn't allow MATCH after CREATE without WITH + needsWithClause := true + // Only process tags if they exist if ev.Tags != nil { for _, tagItem := range *ev.Tags { @@ -150,6 +154,15 @@ CREATE (e)-[:AUTHORED_BY]->(a) paramName := fmt.Sprintf("eTag_%d", eTagIndex) params[paramName] = tagValue + // Add WITH clause before first OPTIONAL MATCH to transition from CREATE to MATCH + if needsWithClause { + cypher += ` +// Carry forward event and author nodes for tag processing +WITH e, a +` + needsWithClause = false + } + cypher += fmt.Sprintf(` // Reference to event (e-tag) OPTIONAL MATCH (ref%d:Event {id: $%s}) diff --git a/pkg/version/version b/pkg/version/version index e6ad33a..70a2a4c 100644 --- a/pkg/version/version +++ b/pkg/version/version @@ -1 +1 @@ -v0.31.8 \ No newline at end of file +v0.31.9 \ No newline at end of file