Skip to content

Switch Bolt protocol version to dedicated type#1321

Merged
MaxAake merged 16 commits into
6.xfrom
stringify-bolt-versions
Sep 29, 2025
Merged

Switch Bolt protocol version to dedicated type#1321
MaxAake merged 16 commits into
6.xfrom
stringify-bolt-versions

Conversation

@MaxAake

@MaxAake MaxAake commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

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()) {

Copy link
Copy Markdown

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.

@AndyHeap-NeoTech AndyHeap-NeoTech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@MaxAake MaxAake merged commit 5cfcbb0 into 6.x Sep 29, 2025
47 checks passed
@MaxAake MaxAake deleted the stringify-bolt-versions branch September 29, 2025 10:50
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