| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | "David E(dot) Wheeler" <david(at)justatheory(dot)com> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Florents Tselai <florents(dot)tselai(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Subject: | Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part |
| Date: | 2025-12-07 11:21:47 |
| Message-ID: | CACJufxHxWKhNcTsmYz428yxUikeUVZz=o6mLNRXpB7F_1oDEng@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
hi.
<para>
<literal>jsonb_path_query('"abc,def,ghi,jkl"',
'$.split_part(",", 2)')</literal>
<returnvalue>"ghi"</returnvalue>
</para></entry>
the return value should be
"def"
?
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>string</replaceable> <literal>.</literal>
<literal>ltrim(<replaceable>characters</replaceable>)</literal>
<returnvalue><replaceable>string</replaceable></returnvalue>
</para>
<para>
String with the longest string containing only spaces or the
characters in <replaceable>characters</replaceable> removed from the
start of <replaceable>string</replaceable>
</para>
<para>
<literal> jsonb_path_query('" hello"', '$.ltrim()')</literal>
<returnvalue>"hello"</returnvalue>
</para>
<para>
<literal>jsonb_path_query('"zzzytest"', '$.ltrim("xyz")')</literal>
<returnvalue>"test"</returnvalue>
</para></entry>
</row>
The actual signature:
<replaceable>characters</replaceable> part is optional, but we didn't
use square brackets
to indicate it's optional.
personally I would prefer list two seperate function signature, like:
<entry role="func_table_entry"><para role="func_signature">
<replaceable>string</replaceable> <literal>.</literal>
<literal>ltrim()</literal>
<returnvalue><replaceable>string</replaceable></returnvalue>
</para>
<para role="func_signature">
<replaceable>string</replaceable> <literal>.</literal>
<literal>ltrim(<replaceable>characters</replaceable>)</literal>
<returnvalue><replaceable>string</replaceable></returnvalue>
</para>
similarly:
string . rtrim([ characters ]) → string
change to
```
string . rtrim() → string
string . rtrim(characters ) → string
```
string . btrim([ characters ]) → string
change to
```
string . btrim() → string
string . btrim([ characters ]) → string
``
would improve the readability, I think.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jelte Fennema-Nio | 2025-12-07 12:16:28 | Re: Something in our JIT code is screwing up PG_PRINTF_ATTRIBUTE |
| Previous Message | Kirill Reshke | 2025-12-07 10:25:08 | Re: Add a property to automatically suspend portals as they produce given number of bytes |