Re: Add jsonb_translate(jsonb, from, to)
От
Chao Li
Тема
Re: Add jsonb_translate(jsonb, from, to)
Дата
Msg-id
7B272236-94DE-4BB1-84CD-77DE3298C1BA@gmail.com
Ответ на
Add jsonb_translate(jsonb, from, to) (Florents Tselai)
Список
Дерево обсуждения
Add jsonb_translate(jsonb, from, to) Florents Tselai <florents.tselai@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Chao Li <li.evan.chao@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Florents Tselai <florents.tselai@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Pavel Stehule <pavel.stehule@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Florents Tselai <florents.tselai@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Peter Eisentraut <peter@eisentraut.org>
Re: Add jsonb_translate(jsonb, from, to) Florents Tselai <florents.tselai@gmail.com>
Re: Add jsonb_translate(jsonb, from, to) Andrew Dunstan <andrew@dunslane.net>
Hi Florents,
Best regards,
Thanks for the patch. I once had the same pain on a similar task, I had to create a PL/SQL function at the time.
I haven’t read the code change yet, but I think the function name jsonb_translate() sounds to generic. To make the name more meaningful, I would suggest a few candidates: jsonb_replace_text(), or jsonb_replace_value(), or jsonb_deep_replace().
Also, I want to understand why do you decide to support only whole word matching?
```
evantest=# select jsonb_translate('{"message": "world"}', 'wor', 'earth');
jsonb_translate
----------------------
{"message": "world"}
(1 row)
```
With this patch, partial match will not result in a replacement.
On Sep 28, 2025, at 01:16, Florents Tselai <florents.tselai@gmail.com> wrote:<v1-0001-Add-jsonb_translate-function.patch>This is a spur of the moment patch really,but while going through the process of translating some json data from Greek to English I found myself wishing for $subject.Inspired by the Unix tr utility.Here's a working v1If others find it useful as well,I'd go ahead with a json implementationAnd an additional parameter to make in-arrays replacement optional.
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
HighGo Software Co., Ltd.
https://www.highgo.com/
В списке pgsql-hackers по дате отправления
От: Mihail Nikalayeu
Дата: