-
-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for generating ULID #2648
Comments
Thank you for your feature proposal. We marked it as "waiting for user interest" for now to gather some feedback from our community:
We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements. We will start the implementation based on:
We do this because:
|
i would tend to agree with @Shinigami92 that, given that one of the key points of ULID is that it embeds a date, having more control over the range of dates embedded in the ULID would be useful. Either you pass it a specific date and it just adds the random part, or you can pass a range of dates and it creates within that range? |
The question is, is the timestamp relevant for our users? |
That's because we only provide UUID v4 right now. |
IMO random ulids and time based ulids are two different feature requests. |
Do you have a need for time based ulids or are you asking for them just because the are in the standard? |
I think just wait until we have a few more upvotes on this. We don't have enough information on how this would be used to make a sensible decision yet. |
Team Decision This has gathered enough interest. We will review brunocleite's PR in the near future: PS: @brunocleite, could you please leave a comment here, so we can assign this issue to you? |
@ST-DDT Yes, you can assign it to me, please. I have updated the PR with a more elaborated solution including support for |
Clear and concise description of the problem
There is another type of unique identifier other than UUID that is called ULID Universally Unique Lexicographically Sortable Identifier.
This type of identifier has the benefit of maintaining a sortable order and is useful as primary keys on databases (mainly NoSQL) to get free date-time sorting out of the box. More information here
ULID is a 26 characters string which the first 10 characters are the timestamp as millis from the epoch and the other 16 are the randomness.
The allowed characters are from
Crockford's Base32
which excludes letters I, L, and O to avoid confusion with digits.Suggested solution
On the code excerpt above it is using the first character as [012] because that would already generate dates up to year 5314 which is more than enough. To confirm this behavior you can go here and try using
2ZZZZZZZZZWZYF0EJ600G2SZHA
as an ULID.Alternative
Allow it to use a
refDate()
like the methods in faker.date?Additional context
Originally proposed by brunocleite at #2524 (comment)
Creating an issue here to allow it to collect upvotes, and discuss possible implementation strategies.
The text was updated successfully, but these errors were encountered: