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

Apoc.trigger.propertiesByKey adding a dynamic label based on newValue vs oldValue does not work #395

Closed
tomasonjo opened this issue Apr 18, 2017 · 2 comments
Assignees

Comments

@tomasonjo
Copy link
Contributor

tomasonjo commented Apr 18, 2017

I have been playing around with apoc.trigger. I created a (a:Test{number:5}) and below query for apoc.trigger, then tried to set the number different, and it does not update labels as it should. Tried out only inner statement with hardcoded values and it works. Using Neo4j 3.1.3 and APOC 3.1.3.6. Nothing in debug.log

CALL apoc.trigger.add('test','UNWIND apoc.trigger.propertiesByKey({assignedNodeProperties},"number") AS prop 
WITH prop.node as n,CASE WHEN toFLOAT(prop.oldValue) < toFLOAT(prop.newValue) THEN "increasing" ELSE "decreasing" END AS label 
CALL apoc.create.addLabels( [n], [label]) YIELD node RETURN "none"', {phase:'after'})
@tomasonjo
Copy link
Contributor Author

Seems like the issue is with adding dynamic labels in trigger.

UNWIND {createdRelationships} as rels WITH startNode(rels) as node set node:What -- works
UNWIND {createdRelationships} as rels WITH startNode(rels) as n WITH n, size((n)-->()) as size SET n:fuKru --works
UNWIND {createdRelationships} as rels WITH startNode(rels) as node WITH node, size((node)-->()) as size set node.size=size -- works

UNWIND {createdRelationships} as rels WITH startNode(rels) as n WITH n, size((n)-->()) as size CALL apoc.create.addLabels( [n], [toString(size)]) YIELD node return distinct("none") -- does not work
UNWIND {createdRelationships} as rels WITH startNode(rels) as n WITH n, size((n)-->()) as size CALL apoc.create.addLabels( [n], ["fu"]) YIELD node return distinct("none") -- does not work

@DanielBerton DanielBerton self-assigned this Apr 20, 2017
@AngeloBusato AngeloBusato removed the docs label Apr 20, 2017
@AngeloBusato AngeloBusato self-assigned this Apr 20, 2017
@inserpio inserpio added the bug label Apr 20, 2017
DanielBerton pushed a commit to AngeloBusato/neo4j-apoc-procedures that referenced this issue May 5, 2017
…ic label based on newValue vs oldValue does not work
@DanielBerton
Copy link

Hi @tomasonjo the problem has been partially resolved, you are trying to update a property when the transaction has been committed {phase:'after'}, but you cannot perform write operations because the transaction is closed. We have just opened an issue #433 to solve it, in the meantime you can use {phase:'before'}.
oldValue and newValue are wrong, correct values are old and new

@jexp jexp closed this as completed in f2e5a24 May 6, 2017
albertodelazzari pushed a commit to albertodelazzari/neo4j-apoc-procedures that referenced this issue Jun 28, 2017
…ic label based on newValue vs oldValue does not work (neo4j-contrib#434)
ncordon added a commit to ncordon/neo4j-apoc-procedures that referenced this issue Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants