-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Support nil or empty uuid #475
Support nil or empty uuid #475
Comments
@ali92hm sorry for the slow response time. Could you elaborate a bit more on the use cases of We are currently extending the API of this library a bit anyways (adding validation and parsing), so adding |
See also #236
My rational for that latter argument is simple: Anywhere you would need to use the nil UUID, there are better, more generalized [Yes, this qualifies as "opinionated software", and there's an argument to be made that it's not our place as module maintainers to make these sorts of judgements. But... worth considering?] |
I'd leave it up to you, but @broofa I agree with the generalized Our use case was having a PG db column where the type is set to UUID and have it non-nullable (because we have very small percentage of the values occasionally being nil) which doesn't make sense to make the full column nullable and potentially deal with missing data. Here is the use case:
We then later found a pg extension that does that automatically. I'm still not fully sold on this being a better solution than using a nullable column (because of the reasons you mentioned). Just thought having it here for the sake of completeness may not be bad. |
What's the benefit here? Does this help DB performance? [Edit: Asking for my own edification. As noted above, as a module maintainer it's probably better to avoid these sorts of debates.] |
I guess I'd be okay adding this. At the end of the day, we're talking about one line of code for the |
Haha, I understand the curiosity part and as I mentioned I'm on the fence about which solution is better. I.e. have the column to be nullable and have null values for missing one or have the column to be non-nullable and have nil uuid for the missing ones. In most of our tables we have the column marked as nullable, but for this table the null values are truly the edge case and not the norm (the value for the column should be present at all times). I'm not sure about db performance, but in my experience making something nullable will accumulate more null values than it is necessary and will lead to null checks all over the code. In this specific case we don't care what the value of the UUID is as long as there is a string value. It's mostly for BI purposes. |
I don't have any opinions on this feature but just saw the issue and wanted to share a nil uuid use case from: https://developer.apple.com/documentation/adsupport/asidentifiermanager/1614151-advertisingidentifier
So, there are a lot of client's which do conditional logic on the backend to handle it. Why Apple does this perplexes me but they do. |
@ali92hm @IsaiahJTurner we have just released |
Yes, I was able to make the following work
|
We have just released |
Sill works, thank you! |
Not really a widely used case, but I want to share why I use the NIL UUID and why I always define it in my code. It is to use it as a name space when creating reproducible uuid3s and uuid5s from strings. One could argue that I don't need the uuid5 because I can straight up use the string itself, but for consistence reasons I need to store my variables in a "UUID only" storage. |
Is your feature request related to a problem? Please describe.
I wanted to go ahead and make a PR for adding nil uuid which is a special case. Before doing the work, I just wanted to double check to see if this has been considered before or there are any objections to it.
You can read more about nil uuid https://en.wikipedia.org/wiki/Universally_unique_identifier#Nil_UUID
Describe the solution you'd like
I was thinking about adding nill to the namespace so the user can write the following code:
I believe that is valid for all versions, so we dont need to implement it under v1, v2, etc.
Let me know your thoughts and I'll get to it.
The text was updated successfully, but these errors were encountered: