Skip to content

Commit b3f9daa

Browse files
committed
Fix Path unpacking when useBigInt is on
The code was trying to do math between Number and BigInt during the Path unpacking. The usage of `toNumber` convert any BigInt|Number|Integer to number in optimal way. Also implements the bind between Relationship and CypherRelatioship to make the code be able to be tested.
1 parent 527d0b4 commit b3f9daa

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

bolt-connection/src/packstream/packstream-v1.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
int,
2424
isInt,
2525
Integer,
26+
toNumber,
2627
Node,
2728
Path,
2829
PathSegment,
@@ -635,7 +636,7 @@ class Unpacker {
635636

636637
for (let i = 0; i < sequence.length; i += 2) {
637638
const nextNode = nodes[sequence[i + 1]]
638-
const relIndex = sequence[i]
639+
const relIndex = toNumber(sequence[i])
639640
let rel
640641

641642
if (relIndex > 0) {

testkit-backend/src/cypher-native-binders.js

+39
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,45 @@ export function nativeToCypher (x) {
3737
}
3838
return { name: 'CypherNode', data: node }
3939
}
40+
if (x instanceof neo4j.types.Relationship) {
41+
const relationship = {
42+
id: nativeToCypher(x.identity),
43+
startNodeId: nativeToCypher(x.start),
44+
endNodeId: nativeToCypher(x.end),
45+
type: nativeToCypher(x.type),
46+
props: nativeToCypher(x.properties)
47+
}
48+
return { name: 'CypherRelationship', data: relationship }
49+
}
50+
if (x instanceof neo4j.types.Path) {
51+
const path = x.segments
52+
.map(segment => {
53+
return {
54+
nodes: [segment.end],
55+
relationships: [segment.relationship]
56+
}
57+
})
58+
.reduce(
59+
(previous, current) => {
60+
return {
61+
nodes: [...previous.nodes, ...current.nodes],
62+
relationships: [
63+
...previous.relationships,
64+
...current.relationships
65+
]
66+
}
67+
},
68+
{ nodes: [x.start], relationships: [] }
69+
)
70+
71+
return {
72+
name: 'CypherPath',
73+
data: {
74+
nodes: nativeToCypher(path.nodes),
75+
relationships: nativeToCypher(path.relationships)
76+
}
77+
}
78+
}
4079
// If all failed, interpret as a map
4180
const map = {}
4281
for (const [key, value] of Object.entries(x)) {

testkit-backend/src/skipped-tests.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ function skip (reason, ...predicate) {
1919
}
2020

2121
const skippedTests = [
22+
skip(
23+
'Not support by the JS driver',
24+
ifEquals('neo4j.sessionrun.TestSessionRun.test_partial_iteration')
25+
),
2226
skip(
2327
'The driver has no support domain_name_resolver',
2428
ifEndsWith('test_should_successfully_acquire_rt_when_router_ip_changes'),

0 commit comments

Comments
 (0)