Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part - Mailing list pgsql-hackers

From jian he
Subject Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part
Date
Msg-id CACJufxHxWKhNcTsmYz428yxUikeUVZz=o6mLNRXpB7F_1oDEng@mail.gmail.com
Whole thread Raw
In response to Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part  (jian he <jian.universality@gmail.com>)
List 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.


--
jian
https://www.enterprisedb.com/



pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: Add a property to automatically suspend portals as they produce given number of bytes
Next
From: Jelte Fennema-Nio
Date:
Subject: Re: Something in our JIT code is screwing up PG_PRINTF_ATTRIBUTE