Question

This kind of query used to work in neo4j 2.m06, but in the stable 2.0 returns an error like "Argument to WHEN is not a predicate"

MATCH (n), (u)
WHERE id(u)=1 

RETURN 

  n.id AS id , 
  n.prop AS prop,
  CASE
    WHEN (u)-[:loves]->(n) THEN 1
    ELSE 0
  END AS loving

ORDER BY id DESC

how am I supposed to express this kind of conditions?

Many thanks you

Was it helpful?

Solution

I think you found a bug, please report it as an issue at http://github.com/neo4j/neo4j/issues

Here is a workaround for you:

MATCH (n), (u)
WHERE id(u)=1 

RETURN 

  n.id AS id , 
  n.prop AS prop,
  CASE
    WHEN size((u)-[:loves]->(n)) > 0 THEN 1
    ELSE 0
  END AS loving

ORDER BY id DESC

Might be expensive though to match all nodes for n in your grpah.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top