Unexpected query result with the Javascript driver
databu opened this issue · 1 comments
databu commented
I'm getting an unexpected result for a query using the Javascript driver. When I run the exact same query directly in Neo4j Desktop on the same DB, I'm getting the expected result.
- Neo4j version: Enterprise 4.1.3, Enterprise 4.2.1 (from Neo4j Desktop 1.4.9)
- Neo4j Mode: 4.1.3: Single instance, 4.2.1 run from Neo4j Desktop 1.4.9
- Driver version: Javascript driver 4.3.4
- Operating system: Client and Neo4j Desktop DB on MacOS 11.2.3, Enterprise 4.1.3 server in a Docker image on AWS
Steps to reproduce
- Start Neo4j Desktop (1.4.9) and create a new DB (mine is Enterprise version 4.2.1)
- Connect to the DB with the Javascript driver 4.3.4 , create a read
tx
and runconst result = await tx.run(query)
, wherequery
has
OPTIONAL MATCH (source:Address { __id__address: 'test1' })
OPTIONAL MATCH (source)-[targetRel:feedback|interaction]-(target:Asset)
WITH source, source { target, targetRel: collect(targetRel)[0] } as directTargetInfo
WITH source, collect(directTargetInfo) as directTargetInfos
WITH source, directTargetInfos, [ directTargetInfo IN directTargetInfos | id(directTargetInfo.target) ] AS foundTargetIds
OPTIONAL MATCH (source)-[peerRel:social|interaction]-(peer:Address)-[targetRel:feedback|interaction]-(target:Asset)
WHERE NOT id(target) IN foundTargetIds
WITH foundTargetIds, directTargetInfos, source { target, peer, peerRel: collect(peerRel)[0], targetRel: collect(targetRel)[0] } as indirectTargetInfo
WITH foundTargetIds, directTargetInfos, collect(indirectTargetInfo) as indirectTargetInfos
WITH directTargetInfos, indirectTargetInfos, apoc.coll.union(foundTargetIds, [ indirectTargetInfo IN indirectTargetInfos | id(indirectTargetInfo.target) ]) AS foundTargetIds
OPTIONAL MATCH (nonRelatedTarget:Asset)
WHERE NOT id(nonRelatedTarget) IN foundTargetIds
RETURN directTargetInfos, indirectTargetInfos, collect(nonRelatedTarget) AS nonRelatedTargets;
Expected behavior
JSON.stringify(queryResult.records.map(record => record.toObject()))
should be
[
{
"directTargetInfos":[],
"indirectTargetInfos":[],
"nonRelatedTargets":[]
}
]
Indeed, when running this query directly in Neo4j Desktop, "Response" under the "Code" tab is:
[
{
"keys":[
"directTargetInfos",
"indirectTargetInfos",
"nonRelatedTargets"
],
"length":3,
"_fields":[
[],
[],
[]
],
"_fieldLookup":{
"directTargetInfos":0,
"indirectTargetInfos":1,
"nonRelatedTargets":2
}
}
]
Actual behavior
JSON.stringify(queryResult.records.map(record => record.toObject()))
is
[
{
"directTargetInfos":[
{
"target":null,
"targetRel":null
}
],
"indirectTargetInfos":[
{
"peerRel":null,
"targetRel":null,
"peer":null,
"target":null
}
],
"nonRelatedTargets":[]
}
]
databu commented
Made a mistake, connected to the wrong DB.