Browse Source

fix bug in cypher code that breaks queries

main
mleku 1 month ago
parent
commit
feae79af1a
No known key found for this signature in database
  1. 13
      pkg/neo4j/save-event.go
  2. 2
      pkg/version/version

13
pkg/neo4j/save-event.go

@ -134,6 +134,10 @@ CREATE (e)-[:AUTHORED_BY]->(a)
eTagIndex := 0 eTagIndex := 0
pTagIndex := 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 // Only process tags if they exist
if ev.Tags != nil { if ev.Tags != nil {
for _, tagItem := range *ev.Tags { for _, tagItem := range *ev.Tags {
@ -150,6 +154,15 @@ CREATE (e)-[:AUTHORED_BY]->(a)
paramName := fmt.Sprintf("eTag_%d", eTagIndex) paramName := fmt.Sprintf("eTag_%d", eTagIndex)
params[paramName] = tagValue 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(` cypher += fmt.Sprintf(`
// Reference to event (e-tag) // Reference to event (e-tag)
OPTIONAL MATCH (ref%d:Event {id: $%s}) OPTIONAL MATCH (ref%d:Event {id: $%s})

2
pkg/version/version

@ -1 +1 @@
v0.31.8 v0.31.9
Loading…
Cancel
Save