Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (extremely) slow data parsing in certain cases #875

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/shared/services/bolt/applyGraphTypes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,41 @@ describe('applyGraphTypes', () => {
const typedDate = applyGraphTypes(rawDate)
expect(typedDate).toBeInstanceOf(neo4j.types.Time)
})
test('recursivelyTypeGraphItems with a bolt response data structure', () => {
// Given
const createDate = hour =>
new neo4j.types.Time(
neo4j.int(hour),
neo4j.int(0),
neo4j.int(0),
neo4j.int(0),
neo4j.int(0)
)
const boltResponse = {
records: [
new neo4j.types.Record(['mydate'], [createDate(12)]),
new neo4j.types.Record(['mydate'], [createDate(2)])
],
summary: {}
}

// When
const forTransport = recursivelyTypeGraphItems(boltResponse)

// Then
expect(forTransport.records[0]._fields[0]).toEqual({
hour: { high: 0, low: 12, 'transport-class': 'Integer' },
minute: { high: 0, low: 0, 'transport-class': 'Integer' },
nanosecond: { high: 0, low: 0, 'transport-class': 'Integer' },
second: { high: 0, low: 0, 'transport-class': 'Integer' },
timeZoneOffsetSeconds: {
high: 0,
low: 0,
'transport-class': 'Integer'
},
'transport-class': 'Time'
})
})
test('should identify time in nodes in paths with refs for start and end', () => {
const date = new neo4j.types.Time(11, 1, 12, 3600, 0)
const start = new neo4j.types.Node(neo4j.int(1), ['From'], { date })
Expand Down
4 changes: 3 additions & 1 deletion src/shared/services/bolt/boltMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ export const recursivelyTypeGraphItems = (item, types = neo4j.types) => {
return tmp
}
if (neo4j.isInt(item)) {
return safetlyAddObjectProp(item, reservedTypePropertyName, 'Integer')
const tmp = { ...item }
safetlyAddObjectProp(tmp, reservedTypePropertyName, 'Integer')
return tmp
}
if (typeof item === 'object') {
let typedObject = {}
Expand Down