Skip to content

Bug in a custom Cypher Query with many SpEL expressions #2947

@Melouw

Description

@Melouw

Hello, this is my first time writing on github, so I apologize if I'm doing something wrong.

cypherQuery = cypherQuery.replace("$" + key, ((Neo4jSpelSupport.LiteralReplacement) value).getValue());

An error was detected in custom Cypher if you use many SpEL expressions
If there are more than 10 SpEL expressions in Query, all expressions named “$__SpEL__10” and onwards, are replaced with the value “$__SpEL__1”

For example, here is my preprepared cypherQuery:

MATCH (comp: Component
  where comp.name =~ $__SpEL__0
)
$__SpEL__1 MATCH (comp)<-[ownerOf: OWNER_OF]-(team: Team $__SpEL__2)
$__SpEL__3 MATCH (comp)<-[con: `CONTAINS`]-(system: System $__SpEL__4)
$__SpEL__5 MATCH (comp)-[u: USES]->(t: Techstack $__SpEL__6)
$__SpEL__7 MATCH(comp)<-[to: TARGET_OBJECT]-(cr:CheckResult)-[crOf: RESULT_OF]->(ccr:Check)
WITH comp,collect(u) as uList, collect(t) as tList, collect(con) as conList ,collect(system) as systemList, collect(ownerOf) as ownerOfList, collect(team) as teamList,collect(to) as toList, collect(cr) as crList, collect(crOf) as crOfList, collect(ccr) as ccrList
$__SpEL__8
$__SpEL__9
$__SpEL__10
RETURN comp, uList, tList, conList, systemList, ownerOfList, teamList, toList, crList, crOfList, ccrList
$__SpEL__11
SKIP $skip LIMIT $limit

After calling cypherQuery.replace I get the string $__SpEL__1 = "OPTIONAL"

MATCH (comp: Component
  where comp.name =~ $__SpEL__0
)
OPTIONAL MATCH (comp)<-[ownerOf: OWNER_OF]-(team: Team $__SpEL__2)
$__SpEL__3 MATCH (comp)<-[con: `CONTAINS`]-(system: System $__SpEL__4)
$__SpEL__5 MATCH (comp)-[u: USES]->(t: Techstack $__SpEL__6)
$__SpEL__7 MATCH(comp)<-[to: TARGET_OBJECT]-(cr:CheckResult)-[crOf: RESULT_OF]->(ccr:Check)
WITH comp,collect(u) as uList, collect(t) as tList, collect(con) as conList ,collect(system) as systemList, collect(ownerOf) as ownerOfList, collect(team) as teamList,collect(to) as toList, collect(cr) as crList, collect(crOf) as crOfList, collect(ccr) as ccrList
$__SpEL__8
$__SpEL__9
OPTIONAL0 // <--- there should be a different value here
RETURN comp, uList, tList, conList, systemList, ownerOfList, teamList, toList, crList, crOfList, ccrList
OPTIONAL1 // <--- there should be a different value here
SKIP $skip LIMIT $limit

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions