Skip to content

Commit 19b4a1e

Browse files
committed
Merge branch '1.7' into 2.0
2 parents 9c9abbe + fe7f37a commit 19b4a1e

File tree

9 files changed

+113
-64
lines changed

9 files changed

+113
-64
lines changed

package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ const logging = {
188188
*
189189
* // Specify socket connection timeout in milliseconds. Numeric values are expected. Negative and zero values
190190
* // result in no timeout being applied. Connection establishment will be then bound by the timeout configured
191-
* // on the operating system level. Default value is 5000, which is 5 seconds.
192-
* connectionTimeout: 5000, // 5 seconds
191+
* // on the operating system level. Default value is 30000, which is 30 seconds.
192+
* connectionTimeout: 30000, // 30 seconds
193193
*
194194
* // Make this driver always return native JavaScript numbers for integer values, instead of the
195195
* // dedicated {@link Integer} class. Values that do not fit in native number bit range will be represented as

src/internal/bolt-protocol-v3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const noOpObserver = new StreamObserver()
2929

3030
export default class BoltProtocol extends BoltProtocolV2 {
3131
transformMetadata (metadata) {
32-
if (metadata.t_first) {
32+
if ('t_first' in metadata) {
3333
// Bolt V3 uses shorter key 't_first' to represent 'result_available_after'
3434
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
3535
metadata.result_available_after = metadata.t_first
3636
delete metadata.t_first
3737
}
38-
if (metadata.t_last) {
38+
if ('t_last' in metadata) {
3939
// Bolt V3 uses shorter key 't_last' to represent 'result_consumed_after'
4040
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
4141
metadata.result_consumed_after = metadata.t_last

src/internal/channel-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { newError, SERVICE_UNAVAILABLE } from '../error'
2121
import { ENCRYPTION_OFF, ENCRYPTION_ON } from './util'
2222

23-
const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000 // 5 seconds by default
23+
const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default
2424

2525
const ALLOWED_VALUES_ENCRYPTED = [
2626
null,

src/result-summary.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ class ProfiledPlan {
174174
this.operatorType = profile.operatorType
175175
this.identifiers = profile.identifiers
176176
this.arguments = profile.args
177-
this.dbHits = profile.args.DbHits.toInt()
178-
this.rows = profile.args.Rows.toInt()
177+
this.dbHits = intValue(profile.args.DbHits)
178+
this.rows = intValue(profile.args.Rows)
179179
this.children = profile.children
180180
? profile.children.map(child => new ProfiledPlan(child))
181181
: []
@@ -208,11 +208,9 @@ class StatementStatistics {
208208
}
209209
Object.keys(statistics).forEach(index => {
210210
// To camelCase
211-
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = isInt(
211+
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = intValue(
212212
statistics[index]
213213
)
214-
? statistics[index].toInt()
215-
: statistics[index]
216214
})
217215
}
218216

@@ -329,9 +327,9 @@ class Notification {
329327
return {}
330328
}
331329
return {
332-
offset: pos.offset.toInt(),
333-
line: pos.line.toInt(),
334-
column: pos.column.toInt()
330+
offset: intValue(pos.offset),
331+
line: intValue(pos.line),
332+
column: intValue(pos.column)
335333
}
336334
}
337335
}
@@ -354,6 +352,10 @@ class ServerInfo {
354352
}
355353
}
356354

355+
function intValue (value) {
356+
return isInt(value) ? value.toInt() : value
357+
}
358+
357359
const statementType = {
358360
READ_ONLY: 'r',
359361
READ_WRITE: 'rw',

test/internal/channel-config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('#unit ChannelConfig', () => {
109109
it('should have connection timeout by default', () => {
110110
const config = new ChannelConfig(null, {}, '')
111111

112-
expect(config.connectionTimeout).toEqual(5000)
112+
expect(config.connectionTimeout).toEqual(30000)
113113
})
114114

115115
it('should respect configured connection timeout', () => {

test/resources/boltstub/v3/acquire_endpoints_three_servers_set_1.script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
!: BOLT 3
22
!: AUTO HELLO
3+
!: AUTO GOODBYE
34

45
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
56
PULL_ALL

test/resources/boltstub/v3/acquire_endpoints_three_servers_set_2.script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
!: BOLT 3
22
!: AUTO HELLO
33
!: AUTO RESET
4+
!: AUTO GOODBYE
45

56
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
67
PULL_ALL

test/summary.test.js

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,75 @@
1919

2020
import neo4j from '../src'
2121
import sharedNeo4j from './internal/shared-neo4j'
22-
import { ServerVersion, VERSION_4_0_0 } from '../src/internal/server-version'
2322

2423
describe('#integration result summary', () => {
25-
let driver, session, serverVersion
24+
describe('default driver', () => {
25+
let driver, session
2626

27-
beforeEach(async () => {
28-
driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken)
29-
session = driver.session()
27+
beforeEach(done => {
28+
driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken)
29+
session = driver.session()
3030

31-
serverVersion = await sharedNeo4j.cleanupAndGetVersion(driver)
31+
session.run('MATCH (n) DETACH DELETE n').then(done)
32+
})
33+
34+
afterEach(() => {
35+
driver.close()
36+
})
37+
38+
it('should get result summary', done => {
39+
verifySummary(session, done)
40+
})
41+
42+
it('should get plan from summary', done => {
43+
verifyPlan(session, done)
44+
})
45+
46+
it('should get profile from summary', done => {
47+
verifyProfile(session, done)
48+
})
49+
50+
it('should get notifications from summary', done => {
51+
verifyNotifications(session, 'EXPLAIN MATCH (n), (m) RETURN n, m', done)
52+
})
3253
})
3354

34-
afterEach(async () => {
35-
await driver.close()
55+
describe('driver with lossless integers disabled', () => {
56+
let driver, session
57+
58+
beforeEach(done => {
59+
driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken, {
60+
disableLosslessIntegers: true
61+
})
62+
session = driver.session()
63+
64+
session.run('MATCH (n) DETACH DELETE n').then(done)
65+
})
66+
67+
afterEach(() => {
68+
driver.close()
69+
})
70+
71+
it('should get result summary', done => {
72+
verifySummary(session, done)
73+
})
74+
75+
it('should get plan from summary', done => {
76+
verifyPlan(session, done)
77+
})
78+
79+
it('should get profile from summary', done => {
80+
verifyProfile(session, done)
81+
})
82+
83+
it('should get notifications from summary', done => {
84+
verifyNotifications(session, 'EXPLAIN MATCH (n), (m) RETURN n, m', done)
85+
})
3686
})
3787

38-
it('should get result summary', done => {
39-
// When & Then
88+
function verifySummary (session, done) {
4089
session.run("CREATE (p:Person { Name: 'Test'})").then(result => {
41-
let summary = result.summary
90+
const summary = result.summary
4291

4392
expect(summary.statement.text).toBe("CREATE (p:Person { Name: 'Test'})")
4493
expect(summary.statement.parameters).toEqual({})
@@ -50,7 +99,7 @@ describe('#integration result summary', () => {
5099
expect(summary.resultConsumedAfter).toBeDefined()
51100
expect(summary.resultAvailableAfter).toBeDefined()
52101

53-
let counters = summary.counters
102+
const counters = summary.counters
54103
expect(counters.nodesCreated()).toBe(1)
55104
expect(counters.nodesDeleted()).toBe(0)
56105
expect(counters.relationshipsCreated()).toBe(0)
@@ -64,31 +113,31 @@ describe('#integration result summary', () => {
64113
expect(counters.constraintsRemoved()).toBe(0)
65114
done()
66115
})
67-
})
116+
}
68117

69-
it('should get plan from summary', done => {
118+
function verifyPlan (session, done) {
70119
session.run('EXPLAIN MATCH (n) RETURN 1').then(result => {
71-
let summary = result.summary
120+
const summary = result.summary
72121
expect(summary.plan).toBeDefined()
73122
expect(summary.profile).toBe(false)
74123

75-
let plan = summary.plan
124+
const plan = summary.plan
76125
expect(plan.arguments).toBeDefined()
77126
expect(plan.children).toBeDefined()
78127
expect(plan.identifiers).toBeDefined()
79128
expect(plan.operatorType).toBeDefined()
80129
done()
81130
})
82-
})
131+
}
83132

84-
it('should get profile from summary', done => {
133+
function verifyProfile (session, done) {
85134
session.run('PROFILE RETURN 1').then(result => {
86-
let summary = result.summary
135+
const summary = result.summary
87136
expect(summary.plan).toBeDefined()
88137
expect(summary.profile).toBeDefined()
89138

90-
let profile = summary.profile
91-
let plan = summary.plan
139+
const profile = summary.profile
140+
const plan = summary.plan
92141

93142
verifyProfileAndPlanAreEqual(profile, plan)
94143

@@ -97,18 +146,14 @@ describe('#integration result summary', () => {
97146

98147
done()
99148
})
100-
})
101-
102-
it('should get notifications from summary', done => {
103-
if (serverVersion.compareTo(VERSION_4_0_0) >= 0) {
104-
pending('seems to be flaky')
105-
}
149+
}
106150

107-
session.run('EXPLAIN MATCH (n), (m) RETURN n, m').then(result => {
108-
let summary = result.summary
151+
function verifyNotifications (session, statement, done) {
152+
session.run(statement).then(result => {
153+
const summary = result.summary
109154
expect(summary.notifications).toBeDefined()
110155
expect(summary.notifications.length).toBe(1)
111-
let notification = summary.notifications[0]
156+
const notification = summary.notifications[0]
112157

113158
expect(notification.code).toBeDefined()
114159
expect(notification.title).toBeDefined()
@@ -118,7 +163,7 @@ describe('#integration result summary', () => {
118163

119164
done()
120165
})
121-
})
166+
}
122167

123168
function verifyProfileAndPlanAreEqual (profile, plan) {
124169
expect(profile.arguments).toBe(plan.arguments)

0 commit comments

Comments
 (0)