Report: Strange behavior query

Hi,
I noticed a strange behavior of Neo4j desktop. ( Neo4j Browser version: [5.6.0])
The result of the query with the same property is different.

First query:
// Double but result different
MATCH (data:CableInformation)
return data.lengthNrLocaLCablesPulled,
data.lengthNrLocalCablesPulled

The first data.lengthNrLocaLCablesPulled returned 300
The second data.lengthNrLocaLCablesPulled returned null

The first query is even more strange because the same query (seond one) gives an error:
Multiple result columns with the same name are not supported.
Second query:
// Double with error
MATCH (data:CableInformation)
RETURN data.lengthNrLocaLCablesPulled,
data.lengthNrLocaLCablesPulled

I believe in the second property "data.lengthNrLocalCablesPulled" in the first query consist of an strange character.

In the picture below you noticed the same property "data.lengthNrLocaLCablesPulled" two times.

I reproduce this behavior by copying both queries into Neo4j desktop after executing the query below.

Code to generate node "CableInformation":
//Example V1.3
// 01. Delete all
MATCH (all) DETACH DELETE all;

CREATE (cable1:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable2:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"2", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable3:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"3", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable4:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"4", connectedFrom:TRUE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable5:Cables {length:100, cableType:"Main", pulled:"Pulled", mainCable:"Routed", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable6:Cables {length:0, cableType:"Main", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});
CREATE (cable7:Cables {length:0, cableType:"Local", pulled:"Not Pulled", mainCable:"Not Routed", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable8:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"2", connectedFrom:TRUE, connectedTo:TRUE, description:"[Lt-Supply][P]LP7421 Supply 2 Lighting"});
CREATE (cable9:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"3", connectedFrom:FALSE, connectedTo:TRUE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable10:Cables {length:100, cableType:"Local", pulled:"Not Pulled", mainCable:"Local", status:"4", connectedFrom:TRUE, connectedTo:FALSE, description:"[Tech-Lt][P]Power Socket"});
CREATE (cable11:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"5", connectedFrom:TRUE, connectedTo:TRUE, description:"[Crew-Lt][P]Art Light (Spare)"});
CREATE (cable12:Cables {length:100, cableType:"Local", pulled:"Pulled", mainCable:"Local", status:"1", connectedFrom:FALSE, connectedTo:FALSE, description:"[RZ][1]24VDC GMDSS Light Red (SPARE)"});

// Create a node
MERGE (cableInfo:CableInformation {nrOfCables:0, //Done
lengthOfCables: 0, //Done
nrOfCablesMain: 0, //Done
lengthCablesMain: 0, //Done
nrOfCablesPulledMain: 0, //Done
lengthNrMainCablesPulled: 0, //Done
nrOfCablesNotPulledMain: 0, //Done
lengthNrMainCablesNotPulled: 0, //Done
nrOfCablesRoutedMain: 0, //Done
lengthNrRoutedMainCables: 0, //Done
nrOfCablesNotRoutedMain: 0,
nrOfCablesLocal: 0, // Done
lengthCablesLocal: 0, //Done
nrOfCablesPulledLocal: 0, // Done
lengthNrLocaLCablesPulled: 0, //Done
nrOfCablesNotPulledLocal: 0, //Done
lengthNrLocaLCablesNotPulled: 0, //Done
nrOfCablesNotRoutedLocal: 0, //Done
nrOfSpareCables: 0, //Done
lengthOfSpareCables: 0, //Done
nrOfSpareCablesMain: 0, //Done
lengthSpareCablesMain: 0, //Done
nrOfSpareCablesLocal: 0, // Done
lengthSpareCablesLocal: 0, //Done
cablesStatusNotDone: 0, //Done
cablesStatusCut: 0, //Done
cablesStatusOnBoardPulled: 0, //Done
cablesStatusBought: 0, //Done
cablesStatusReady: 0, //Done
nrOfCablesConnectedFrom: 0, //Done
nrOfCablesConnectedTo: 0, //Done
nrOfCablesConnectedTotaly: 0 //Done
}
);

MATCH (cables:Cables)
WHERE cables.cableType IN ["Main", "Local"] OR cables.pulled IN ["Pulled", "Not Pulled"]
WITH cables.cableType as type,
cables.pulled as pulledType,
count(*) as countOfCables,
sum(cables.length) as sumOfLengths
WITH {type: type,
pulledType: pulledType,
nrOfCables: countOfCables,
lengthOfCables: sumOfLengths} as typeData
WITH COLLECT(typeData) as collectionData
MATCH (cableInfo:CableInformation)
WITH cableInfo,
collectionData
// Collection start with index 0
SET cableInfo.nrOfCablesPulledMain = collectionData[1].nrOfCables,
cableInfo.lengthNrMainCablesPulled = collectionData[1].lengthOfCables,
cableInfo.nrOfCablesNotPulledMain = collectionData[0].nrOfCables,
cableInfo.lengthNrMainCablesNotPulled = collectionData[0].lengthOfCables,
cableInfo.nrOfCablesPulledLocal = collectionData[3].nrOfCables,
cableInfo.lengthNrLocaLCablesPulled = collectionData[3].lengthOfCables,
cableInfo.nrOfCablesNotPulledLocal = collectionData[2].nrOfCables,
cableInfo.lengthNrLocaLCablesNotPulled = collectionData[2].lengthOfCables
// Node variable will be loaded after the SET is finished.
SET cableInfo.nrOfCablesMain = cableInfo.nrOfCablesPulledMain + cableInfo.nrOfCablesNotPulledMain,
cableInfo.lengthCablesMain = cableInfo.lengthNrMainCablesPulled + cableInfo.lengthNrMainCablesNotPulled,
cableInfo.nrOfCablesLocal = cableInfo.nrOfCablesPulledLocal + cableInfo.nrOfCablesNotPulledLocal,
cableInfo.lengthCablesLocal= cableInfo.lengthNrLocaLCablesPulled + cableInfo.lengthNrLocaLCablesNotPulled
// Node variable will be loaded after the SET is finished.
SET cableInfo.nrOfCables = cableInfo.nrOfCablesMain + cableInfo.nrOfCablesLocal,
cableInfo.lengthOfCables = cableInfo.lengthCablesMain + cableInfo.lengthCablesLocal;

@r.kempers

What version of Neo4j ? From Browser and left side bar, click 1st icon and scroll to bottom

DBMS: Version 5.3.0

Neo4j Browser version: [5.6.0]
Neo4j Server version: [5.3.0]

@r.kempers

Thanks for this detail. As 5.3.0 was released December 2022 and our latest 5.x is 5.7.0 can you retry with 5.7.0? or are your required to uses 5.3.0

@ dana

Thanks for your response.

Im just setting up a project with the latest version.

Will come back with the result later on.

You are not allowed two output values with the same name. This makes sense. You can alias them with different names and it be allowed.

For the first, your properties have a different spelling of ‘local’. One ends in an uppercase ‘L’ and the other a lowercase ‘l’ property, thus they are different.

The second on must be the incorrect spelling as it’s value is null.

1 Like

@glilienfield

You are very sharp.
The first query does have indeed a difference which I didnt noticed.
I have checked with Excel but unfortunately my check was not correct.

Was a blind spot.

1 Like