Postgres random text in JSONB column Following is the query I'm using to scrub some fields in the JSONB column. I'm trying to radomize the first and last name so would like to use something like md5(random()::text) as values.
    update people set
    data = to_jsonb(data) || '{&quot;firstName&quot;: &quot;random_text&quot;, &quot;lastName&quot;: &quot;random_text&quot;}'
    where id = 'b3c09005-7afb-4ad6-922d-76078875e59e';

I tried replacing random_text with md5(...) but I get an error

&quot;DETAIL:  Token &quot;md5&quot; is invalid.&quot;.

I also tried using || to concat but that didn't work either.
You have to use the md5 hash as a part of the string so you have to concat it


CREATE TABLE people(&quot;id&quot; varchar(50), &quot;data&quot; jsonb,&quot;firstName&quot; text, &quot;lastName&quot; text)




    update people set
    data = to_jsonb(data) || ('{&quot;firstName&quot;: &quot;' || MD5('PostgreSQL MD5') || '&quot;, &quot;lastName&quot;: &quot;' || MD5('PostgreSQL MD5') || '&quot;}')::jsonb
    where id = 'b3c09005-7afb-4ad6-922d-76078875e59e';


db&lt;&gt;fiddle here
still md5 is old and not very secure, so you should use a more secure version