Skip to content

Conversation

MaxAake
Copy link
Contributor

@MaxAake MaxAake commented Aug 21, 2025

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

@MaxAake MaxAake changed the title Stringify Bolt protocol version Switch to Bolt protocol version object Aug 22, 2025
@MaxAake MaxAake changed the title Switch to Bolt protocol version object Switch Bolt protocol version to dedicated type Aug 22, 2025
if (!(version instanceof ProtocolVersion) || version === undefined || version === null) {
throw newError('Unknown Bolt protocol version: ' + version)
}
switch (version.toString()) {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants