orm icon indicating copy to clipboard operation
orm copied to clipboard

💡 Add ULID support

Open meekstellar opened this issue 2 years ago • 6 comments

I have an idea!

Basically we use UUID for our applications, but new ULID identifier a quite bit faster and ensures that the IDs can be monotonically ordered and can be sorted even when generated within a millisecond.

Here is the ULID specs:

  • 128-bit compatibility with UUID
  • 1.21e+24 unique ULIDs per millisecond
  • Lexicographically sortable!
  • Canonically encoded as a 26 character string, as opposed to the 36 character UUID
  • Uses Crockford’s base32 for better efficiency and readability (5 bits per character)
  • Case insensitive
  • No special characters (URL safe)
  • Monotonic sort order (correctly detects and handles the same millisecond)

meekstellar avatar Jun 28 '23 09:06 meekstellar

FYI: We have supporting for UUID v7 in https://github.com/cycle/entity-behavior-uuid You can read about it there https://uuid.ramsey.dev/en/stable/rfc4122/version7.html

roxblnfk avatar Jun 28 '23 14:06 roxblnfk

I use Ulid for almost all entities PKs wrapped in ValueInterface, it works great. I'm thinking about switching to a entity-behavior, but turns out I actually like the control I have over values assignment, so I'm used to setting PKs manually.

rauanmayemir avatar Jun 29 '23 05:06 rauanmayemir

There's ought to be another plugin entity-behavior-uid that uses Symfony Uid package. 🙈 (Symfony Uid also supports Ulid among regular UUIDs)

rauanmayemir avatar Jun 29 '23 05:06 rauanmayemir

I use Ulid for almost all entities PKs wrapped in ValueInterface, it works great. I'm thinking about switching to a entity-behavior, but turns out I actually like the control I have over values assignment, so I'm used to setting PKs manually.

The same. I prefer to generate UUID in a separated service.

roxblnfk avatar Jun 29 '23 09:06 roxblnfk

For further clarity, I found this draft document beneficial: UUIDv6 Draft. After examining it, I suggest that ULID could be substituted with UUIDv7. The good news is that the ramsey and cycle packages supports UUIDv7 and should cater to your requirements.

lotyp avatar Aug 17 '23 16:08 lotyp