Open themusicman opened 8 months ago
It's because the resolution is 1ms and all your uuids are generated in the same millisecond. I'm facing the same problem, it cases flaky tests. You need to either add 1ms delay before generating the next uuid. @bitwalker It would be good to have a "special" version that has better time resolution for use in unit tests. It could be named unsafe_uuidv7 so people won't use it by accident. I proposed it also in ex_machina https://github.com/beam-community/ex_machina/issues/463
I am attempting to sort a list of UUIDs and when I use
Uniq.UUID.compare
to do that I am not getting the list of UUIDs not sorted properly.Here is the code used to produce and sort the UUIDs and debugging output.
Produce the UUIDs:
Output:
Create the list and reverse it:
Output:
Attempt to sort them:
Sorted output: