-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Description
As ulid is saved as a binary field in the db and represented as base32 in the application side, it's hard and unconvenient to manipulate them. It would be interesting to improve the DX.
Example
1st idea : bin/console inspect:ulid
could show an hexadecimal representation of the ulid :
/app # bin/console ulid:inspect 01FF2QE789KQSBK3HWT65S9H7S
---------------------- --------------------------------------
Label Value
---------------------- --------------------------------------
toBase32 (canonical) 01FF2QE789KQSBK3HWT65S9H7S
...
toHex 0x017BC5771D099DF2B98E3CD18B94C4F9
Thus, the hex representation can be used directly in a SQL request to filter a specific ulid :
SELECT * FROM my_table WHERE id=0x017BC5771D099DF2B98E3CD18B94C4F9
A second idea is to bring some SQL routimes to manipulate ulid directly in SQL as you can see in this gist.
SELECT * FROM my_table WHERE id=ULID_DECODE('01FF2QE789KQSBK3HWT65S9H7S')
It could be a Doctrine migration that the developer is free to use in his app.
bigfoot90 and Tetragramat