public inbox for [email protected]  
help / color / mirror / Atom feed
From: David E. Wheeler <[email protected]>
To: Florents Tselai <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Robert Haas <[email protected]>
Cc: Alexander Korotkov <[email protected]>
Cc: pgsql-hackers <[email protected]>
Cc: Andrew Dunstan <[email protected]>
Subject: Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part
Date: Sat, 12 Jul 2025 14:24:25 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+v5N40+gPfir3ShsA53SLWeQa5eMy7Bm3vnOKLa5YLNEwZO7w@mail.gmail.com>
References: <CA+v5N40sJF39m0v7h=QN86zGp0CUf9F1WKasnZy9nNVj_VhCZQ@mail.gmail.com>
	<[email protected]>
	<CAPpHfdtGhn_5jfLoepOScyqT+FXYB9QtV-OEprychDcMJco7mw@mail.gmail.com>
	<CA+v5N42PVJH3HbwLE1yC75XR6E5zGnCCdtSUXfgFwtGyPP8XYg@mail.gmail.com>
	<CA+Tgmob03B6h1SMsi7vs9uOX+vrqg_tyhh--mKC3BaTJ08qKYA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CA+v5N40+gPfir3ShsA53SLWeQa5eMy7Bm3vnOKLa5YLNEwZO7w@mail.gmail.com>

On Jul 12, 2025, at 00:07, Florents Tselai <[email protected]> wrote:

> To recap so far; 
> 
> - I like your changes and renames on the parser/lexer; it indeed looks much cleaner now and will help with future improvements.

Thanks!

> - I also like the addition of executeStringInternalMethod ; it'll help us add more stuff in the future (reminder that for the original patch I implemented the methods I'd like more, but string operations are quite more).

Agreed.

> - AFAICT no test cases / results have changed with your versions; is this correct ?

I made some minor changes, notably to test alternate trim values and a negative position passed to split_part():

```patch
--- a/src/test/regress/sql/jsonb_jsonpath.sql
+++ b/src/test/regress/sql/jsonb_jsonpath.sql
@@ -627,7 +627,7 @@ rollback;
 select jsonb_path_query('"   hello   "', '$.ltrim(" ")');
 select jsonb_path_query('"   hello   "', '$.ltrim(" ")');
 select jsonb_path_query('"   hello   "', '$.ltrim()');
-select jsonb_path_query('"   hello   "', '$.ltrim()');
+select jsonb_path_query('"zzzytest"', '$.ltrim("xyz")');
 select jsonb_path_query('null', '$.ltrim()');
 select jsonb_path_query('null', '$.ltrim()', silent => true);
 select jsonb_path_query('[]', '$.ltrim()');
@@ -647,13 +647,13 @@ select jsonb_path_query_array('["  maybe  ", "  yes", "  no"]', '$[*].ltrim().ty
   -- test .rtrim()
 select jsonb_path_query('"   hello   "', '$.rtrim(" ")');
-select jsonb_path_query('"   hello   "', '$.rtrim(" ")');
+select jsonb_path_query('"testxxzx"', '$.rtrim("xyz")');
 select jsonb_path_query('"   hello   "', '$.rtrim()');
 select jsonb_path_query('"   hello   "', '$.rtrim()');
   -- test .btrim()
 select jsonb_path_query('"   hello   "', '$.btrim(" ")');
-select jsonb_path_query('"   hello   "', '$.btrim(" ")');
+select jsonb_path_query('"xyxtrimyyx"', '$.btrim("xyz")');
 select jsonb_path_query('"   hello   "', '$.btrim()');
 select jsonb_path_query('"   hello   "', '$.btrim()');
  @@ -723,6 +723,7 @@ select jsonb_path_query('"hello world"', '$.replace("hello","bye") starts with "
   -- Test .split_part()
 select jsonb_path_query('"abc~@~def~@~ghi"', '$.split_part("~@~", 2)');
+select jsonb_path_query('"abc,def,ghi,jkl"', '$.split_part(",", -2)');
   -- Test string methods play nicely together
 select jsonb_path_query('"hello world"', '$.replace("hello","bye").upper()');
```

Best,

David



Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

view thread (56+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox