-
Notifications
You must be signed in to change notification settings - Fork 154
Switch Bolt protocol version to dedicated type #1321
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
base: 6.x
Are you sure you want to change the base?
Conversation
if (!(version instanceof ProtocolVersion) || version === undefined || version === null) { | ||
throw newError('Unknown Bolt protocol version: ' + version) | ||
} | ||
switch (version.toString()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not hugely experienced in JS, and I know that you can't override the equality operator like you can in some other languages. But is there a way to do the switch without string comparison? Something like:
switch (true) {
case version.equals(BOLT_PROTOCOL_V1):
break;
case version.equals(BOLT_PROTOCOL_V5):
break;
default:
// default case
}
No idea if that would be preferable or idiomatic in JS, but to my C# brain it's preferable.
The selected bolt protocol version is represented as a floating point number in multiple places in the code. This is currently fine, but would cause the whole driver to explode if/when we introduce bolt 5.10 or 6.10.
This PR addresses this tech debt before it causes a larger issue