From: | Florents Tselai <florents(dot)tselai(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | [PATCH] WIP: replace method for jsonpath |
Date: | 2024-09-15 01:15:12 |
Message-ID: | 9A942004-047D-4A4D-BAFC-B45FFDF9B595@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
When working with jsonb/jsonpath, I’ve always wanted more fluent string operations for data cleaning.
Ideally, chaining text processing methods together.
Here’s a draft patch that adds a string replace method.
It works like this
select jsonb_path_query('"hello world"', '$.replace("hello","bye")');
jsonb_path_query
------------------
"bye world"
(1 row)
And looks like plays nicely with existing facilities
select jsonb_path_query('"hello world"', '$.replace("hello","bye") starts with "bye"');
jsonb_path_query
------------------
true
(1 row)
I’d like some initial feedback on whether this is of interested before I proceed with the following:
- I’ve tried respecting the surrounding code, but a more experienced eye can spot some inconsistencies. I’ll revisit those
- Add more test cases (I’ve added the obvious ones, but ideas on more cases are welcome).
- pg upgrades currently fail on CI (see <https://github.com/Florents-Tselai/postgres/pull/3/checks?check_run_id=30154989488>)
- better error handling/reporting: I’ve kept the wording of error messages, but we’ll need something akin to ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION.
- documentation.

From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2024-09-15 02:30:02 | Re: Obsolete comment in pg_stat_statements |
Previous Message | Bruce Momjian | 2024-09-15 00:37:31 | Re: Detailed release notes |