Closed terefang closed 1 year ago
uuid_str
only works with valid UUIDs. And why would you want to create a UUID from the first 16 bytes of the SHA-256 hash? What's the use case here?
like me reference UUIDv3, v5 and v8:
A UUID is generated based on an unspecified name. Names are unique identifiers for an object, resource or similar within an assigned namespace. Starting from a UUID for the namespace, a UUID is generated from the name by forming a byte sequence from the namespace UUID and the name itself and then hashing this byte sequence using MD5 or SHA1. The hash is then distributed among the available UUID bits in a defined manner.
one could call the function more precisely:
my particular real-world use case is that i create "stable unique ids" out of the concatenation of various text-fields in the row, which are then easier to join and reference and can also act as safe ids in other protocols (like rest-urls).
today i have to do this outside of sqlite with scripting re-writing the csv-import.
it would be much simpler to do the csv-import and then issue UPDATE table SET XID=uuidv8_str_sha512(f1 || f2 || f3)
.
i have looked at the code ... a quick win would be to just check if the parameter is "at least" and not "exactly" 16 bytes.
@nalgeon would you agree ?
Sorry, I don't like the idea of uuid_str
truncating its argument. You can always use substr(x, 1, 16)
on the hashcode and then call uuid_str
on the result.
would you accept a pull request for uuid_str_<HASHALGO>
?
No, I don't think so, sorry.
i dont understand
i was only interested of also making other users lifes easer.
sqlean is a really useful contribution to the sqlite community and i hope you keep up the existing work.
today this happens:
if the string or blob is at least 16 bytes long uuid_str() could just take the first 16 bytes and ignore the rest.
in addition a shortcut could be dedicated functions like: