I’m frontend developer and this is my first project where I’m using NextJS with Neo4j by sending Cypher scripts.
My Cypher code is:
OPTIONAL MATCH (o:Organization {name:"Demo AB"})-[]-(source0:System {applikation: "a1"})-[ARCHITECTED_BY:ARCHITECTED_BY]->(target0)
OPTIONAL MATCH (o:Organization {name:"Demo AB"})-[]-(source1:System {applikation: "a1"})-[MAINTAINED_BY:MAINTAINED_BY]->(target1)
OPTIONAL MATCH (o:Organization {name:"Demo AB"})-[]-(source2:System {applikation: "a1"})-[OWNED_BY:OWNED_BY]->(target2)
OPTIONAL MATCH (o:Organization {name:"Demo AB"})-[]-(source3:System {applikation: "a1"})-[SUPPORTED_BY:SUPPORTED_BY]->(target3)
WITH
CASE WHEN target0 IS NOT NULL THEN target0 END AS ARCHITECTED_BY,
CASE WHEN target1 IS NOT NULL THEN target1 END AS MAINTAINED_BY,
CASE WHEN target2 IS NOT NULL THEN target2 END AS OWNED_BY,
CASE WHEN target3 IS NOT NULL THEN target3 END AS SUPPORTED_BY
RETURN ARCHITECTED_BY, MAINTAINED_BY, SUPPORTED_BY, OWNED_BY
When System has only last connection (SUPPORTED_BY) it returns 4 null
╒══════════════╤═════════════╤════════════╤════════╕
│ARCHITECTED_BY│MAINTAINED_BY│SUPPORTED_BY│OWNED_BY│
╞══════════════╪═════════════╪════════════╪════════╡
│null │null │null │null │
└──────────────┴─────────────┴────────────┴────────┘
if system has at least 1 other relation it returns good value:
╒══════════════════════════════════════════════════════════════════════╤═════════════╤══════════════════════════════════════════════════════════════════════╤════════╕
│ARCHITECTED_BY │MAINTAINED_BY│SUPPORTED_BY │OWNED_BY│
╞══════════════════════════════════════════════════════════════════════╪═════════════╪══════════════════════════════════════════════════════════════════════╪════════╡
│(:User {lastName: "Lovelace",firstName: "Ada",phone: "0732323232",emai│null │(:User {firstName: "Edyta",lastName: "Redactello",email: "editor@test.│null │
│l: "[email protected]"}) │ │se"}) │ │
└──────────────────────────────────────────────────────────────────────┴─────────────┴──────────────────────────────────────────────────────────────────────┴────────┘
I can fill this is some small thing but I can’t spot it…
I tried to swap the order, and problem is always with the last relation