Last active
December 23, 2022 02:13
-
-
Save cdmckay/a82261e48a42a3bbd78a to your computer and use it in GitHub Desktop.
How to convert a PostgreSQL UUID to bytea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select decode(replace('45774962-e6f7-41f6-b940-72ef63fa1943'::text, '-', ''), 'hex'); | |
-- And here's how to convert it to the ShortUUID format used in Process Street | |
select replace(encode(substring(decode(replace('45774962-e6f7-41f6-b940-72ef63fa1943'::text, '-', ''), 'hex') from 9 for 8) || | |
substring(decode(replace('45774962-e6f7-41f6-b940-72ef63fa1943'::text, '-', ''), 'hex') from 1 for 8), 'base64'), '=', ''); |
@will thank you!
:)
Also in case you didn’t know (and anyone in the future) there is a _send
function for all data types, if you want to get the internal binary representation of the data. Just something to keep in the back of your mind, I find it's handy to know like once every few years
@will any idea what the use case for void_send
would be? how is it even called?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@will thank you!