Skip to content

Fix how numbers are converted in result summary #481

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

Merged
merged 3 commits into from
Aug 28, 2019
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
122 changes: 62 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"karma-source-map-support": "^1.4.0",
"karma-spec-reporter": "^0.0.32",
"lint-staged": "^8.1.7",
"lodash": "^4.17.11",
"lodash": "^4.17.15",
"lolex": "^4.0.1",
"minimist": "^1.2.0",
"mustache": "^3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/v1/internal/bolt-protocol-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import RequestMessage from './request-message'

export default class BoltProtocol extends BoltProtocolV2 {
transformMetadata (metadata) {
if (metadata.t_first) {
if ('t_first' in metadata) {
// Bolt V3 uses shorter key 't_first' to represent 'result_available_after'
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
metadata.result_available_after = metadata.t_first
delete metadata.t_first
}
if (metadata.t_last) {
if ('t_last' in metadata) {
// Bolt V3 uses shorter key 't_last' to represent 'result_consumed_after'
// adjust the key to be the same as in Bolt V1 so that ResultSummary can retrieve the value
metadata.result_consumed_after = metadata.t_last
Expand Down
18 changes: 10 additions & 8 deletions src/v1/result-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class ProfiledPlan {
this.operatorType = profile.operatorType
this.identifiers = profile.identifiers
this.arguments = profile.args
this.dbHits = profile.args.DbHits.toInt()
this.rows = profile.args.Rows.toInt()
this.dbHits = intValue(profile.args.DbHits)
this.rows = intValue(profile.args.Rows)
this.children = profile.children
? profile.children.map(child => new ProfiledPlan(child))
: []
Expand Down Expand Up @@ -201,11 +201,9 @@ class StatementStatistics {
}
Object.keys(statistics).forEach(index => {
// To camelCase
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = isInt(
this._stats[index.replace(/(-\w)/g, m => m[1].toUpperCase())] = intValue(
statistics[index]
)
? statistics[index].toInt()
: statistics[index]
})
}

Expand Down Expand Up @@ -322,9 +320,9 @@ class Notification {
return {}
}
return {
offset: pos.offset.toInt(),
line: pos.line.toInt(),
column: pos.column.toInt()
offset: intValue(pos.offset),
line: intValue(pos.line),
column: intValue(pos.column)
}
}
}
Expand All @@ -347,6 +345,10 @@ class ServerInfo {
}
}

function intValue (value) {
return isInt(value) ? value.toInt() : value
}

const statementType = {
READ_ONLY: 'r',
READ_WRITE: 'rw',
Expand Down
Loading