Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
út 15. 8. 2023 v 8:04 odesílatel Vik Fearing napsal: > On 8/15/23 07:53, Pavel Stehule wrote: > > út 15. 8. 2023 v 7:48 odesílatel Vik Fearing > > napsal: > > > >> On 8/14/23 15:37, Pavel Stehule wrote: > >>> po 14. 8. 2023 v 15:09 odesílatel Erik Rijkers napsal: > >>> > >>> I think so this can

Re: proposal: jsonb_populate_array

2023-08-14 Thread Vik Fearing
On 8/15/23 07:53, Pavel Stehule wrote: út 15. 8. 2023 v 7:48 odesílatel Vik Fearing napsal: On 8/14/23 15:37, Pavel Stehule wrote: po 14. 8. 2023 v 15:09 odesílatel Erik Rijkers napsal: I think so this can be +/- 40 lines of C code It seems to me like a good candidate for an extension.

Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
út 15. 8. 2023 v 5:12 odesílatel jian he napsal: > \df jsonb_populate_record > List of functions >Schema | Name | Result data type | Argument data > types | Type > > +---+--+---

Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
út 15. 8. 2023 v 7:48 odesílatel Vik Fearing napsal: > On 8/14/23 15:37, Pavel Stehule wrote: > > po 14. 8. 2023 v 15:09 odesílatel Erik Rijkers napsal: > > > >> Op 8/14/23 om 14:51 schreef Pavel Stehule:> po 14. 8. 2023 v 11:32 > >> odesílatel Alvaro Herrera > >> > with proposed function I c

Re: proposal: jsonb_populate_array

2023-08-14 Thread Vik Fearing
On 8/14/23 15:37, Pavel Stehule wrote: po 14. 8. 2023 v 15:09 odesílatel Erik Rijkers napsal: Op 8/14/23 om 14:51 schreef Pavel Stehule:> po 14. 8. 2023 v 11:32 odesílatel Alvaro Herrera > with proposed function I can write > > select jsonb_populate_array(null:date[], > '["2023-07-13"

Re: proposal: jsonb_populate_array

2023-08-14 Thread Vik Fearing
On 8/14/23 15:47, Chapman Flack wrote: On 2023-08-14 09:11, Erik Rijkers wrote:   , '$' returning date[] I certainly like that syntax better. It's not that the "here's a null to tell you the type I want" is terribly unclear, but it seems not to be an idiom I have seen a lot of in PostgreSQL b

Re: proposal: jsonb_populate_array

2023-08-14 Thread jian he
\df jsonb_populate_record List of functions Schema | Name | Result data type | Argument data types | Type +---+--+-+-- pg_catalog | jsonb_populate_record | anyelement

Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
po 14. 8. 2023 v 15:47 odesílatel Chapman Flack napsal: > On 2023-08-14 09:11, Erik Rijkers wrote: > > , '$' returning date[] > > I certainly like that syntax better. > > It's not that the "here's a null to tell you the type I want" > is terribly unclear, but it seems not to be an idiom I have

Re: proposal: jsonb_populate_array

2023-08-14 Thread Chapman Flack
On 2023-08-14 09:11, Erik Rijkers wrote: , '$' returning date[] I certainly like that syntax better. It's not that the "here's a null to tell you the type I want" is terribly unclear, but it seems not to be an idiom I have seen a lot of in PostgreSQL before now. Are there other places it's c

Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
po 14. 8. 2023 v 15:09 odesílatel Erik Rijkers napsal: > Op 8/14/23 om 14:51 schreef Pavel Stehule:> po 14. 8. 2023 v 11:32 > odesílatel Alvaro Herrera > > with proposed function I can write > > > > select jsonb_populate_array(null:date[], > > '["2023-07-13","2023-07-14"]'::jsonb) > > > Not

Re: proposal: jsonb_populate_array

2023-08-14 Thread Erik Rijkers
Op 8/14/23 om 14:51 schreef Pavel Stehule:> po 14. 8. 2023 v 11:32 odesílatel Alvaro Herrera > with proposed function I can write > > select jsonb_populate_array(null:date[], > '["2023-07-13","2023-07-14"]'::jsonb) > Not yet committed, but outstanding SQL/JSON patches (v11) will let you do: sel

Re: proposal: jsonb_populate_array

2023-08-14 Thread Pavel Stehule
po 14. 8. 2023 v 11:32 odesílatel Alvaro Herrera napsal: > On 2023-Aug-14, Pavel Stehule wrote: > > > jsonb_populate_array(anyarray, jsonb) returns anyarray > > > > Usage: > > > > select jsonb_populate_array(null::text[], > '["cust_full_name","cust_email"]') > > I don't understand what this does.

Re: proposal: jsonb_populate_array

2023-08-14 Thread Alvaro Herrera
On 2023-Aug-14, Pavel Stehule wrote: > jsonb_populate_array(anyarray, jsonb) returns anyarray > > Usage: > > select jsonb_populate_array(null::text[], '["cust_full_name","cust_email"]') I don't understand what this does. Can you be more explicit? -- Álvaro Herrera 48°01'N 7°57'

proposal: jsonb_populate_array

2023-08-13 Thread Pavel Stehule
Hi Now, there is no native functionality for conversion from json(b) value to some array. https://stackoverflow.com/questions/76894960/unable-to-assign-text-value-to-variable-in-pgsql/76896112#76896112 It should not be too hard to implement native function jsonb_populate_array jsonb_populate_ar