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)
- 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.

Attachment: v1-0001-jsonpath-replace-method.patch
Description: Binary data

Reply via email to