Open Trupal00p opened 3 years ago
@Trupal00p Thanks, that's helpful! Maybe you could make a pull request to add a note about this to the README? I don't think we should require every user of the generate_ulid()
function to also import this new type.
Your ulid_upper_bound
check may also run into problems if a user chooses to pass a custom prefix to the generate function.
I would add as others pointed out, casting to text (32-bytes) basically doubles the size. Better to cast to uuid (16-bytes). Affects size of indexes.
Howdy thanks for creating this really useful function! To use this more easily, I ended up adding a new domain type for the text result of this function so it can be used more like the uuid type that its replacing. The one extra SQL statement I added:
this add a few standard checks for string length and sets the max value (per the ULID spec) to prevent invalid IDs from sneaking in. It also allows you to use the new ulid type in table creation statements in a clean way:
Was gonna open a PR but since it is such a small change thought this might be easier to add to the discussion here.