kurttheviking / uuid-with-v6-js

UUID Version 6 for Node.js
ISC License
17 stars 6 forks source link

Feature request - byte arrangement for correct sorting in SQL Server's uniqueidentifier #1

Closed oopoopoop closed 3 years ago

oopoopoop commented 4 years ago

Is it a bad idea for this module to support byte rearranging for proper sorting in SQL Server? Here's a short discussion.

The proposed method would rearrange the UUIDv6 bytes yet again. This means that the 4-bit version field will also be moved.

For example: v is the version (6 in this example) aaaaaaaabbbbccc is the timestamp xxxxyyyyyyyyzzzz is the random bytes

aaaaaaaa-bbbb-vccc-xxxx-yyyyyyyyzzzz would be rearranged into yyyyyyyy-zzzz-xxxx-vccc-aaaaaaaabbbb

Thinking more closely though, if we were to keep the version bits, it would only confuse whoever reads the version. Since if it stays as version 6, timestamp would not be where it should be.

If we run the method to rearrange the bytes again, we would get our original UUIDv6.

What do you think?

oopoopoop commented 3 years ago

Bad idea, it is. This should be done outside of this module.

I'm closing this.