Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Melouw opened this issue Sep 4, 2024 · 1 comment
Closed

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

Melouw opened this issue Sep 4, 2024 · 1 comment
Assignees
Labels
type: bug A general bug

Comments

@Melouw
Copy link

Melouw commented Sep 4, 2024

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 4, 2024
@michael-simons michael-simons self-assigned this Sep 4, 2024
@michael-simons
Copy link
Collaborator

Thanks @Melouw This is an excellent report, well done.

And it's kind of embarrassing for me as I had this kind of bug in the past. A fix is on the way.

Thanks a lot!

@michael-simons michael-simons added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 4, 2024
michael-simons added a commit that referenced this issue Sep 4, 2024
michael-simons added a commit that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants