Re: Weird special case in jsonb_concat()

2020-12-21 Thread Tom Lane
"Joel Jacobson" writes: > On Sat, Dec 19, 2020, at 21:35, Tom Lane wrote: >> Here is a proposed patch for that. > In addition, to the user wondering how to append a json array-value "as is", > I think it would be useful to provide an example on how to do this > in the documentation. Done in v13

Re: Weird special case in jsonb_concat()

2020-12-20 Thread Zhihong Yu
Hi, w.r.t. the patch, +select '[3]'::jsonb || '{}'::jsonb; + ?column? +-- + [3, {}] +(1 row) + +select '3'::jsonb || '[]'::jsonb; Should cases where the empty array precedes non-empty jsonb be added ? select '[]'::jsonb || '3'::jsonb; select '{}'::jsonb || '[3]'::jsonb; Cheers

Re: Weird special case in jsonb_concat()

2020-12-19 Thread Joel Jacobson
On Sat, Dec 19, 2020, at 21:35, Tom Lane wrote: >Here is a proposed patch for that. I've tested the patch and "All 202 tests passed". In addition, I've tested it on a json intensive project, which passes all its own tests. I haven't studied the jsonfuncs.c code in detail, but the new code looks

Re: Weird special case in jsonb_concat()

2020-12-19 Thread Pavel Stehule
so 19. 12. 2020 v 21:35 odesílatel Tom Lane napsal: > I wrote: > > However, further experimentation found a case that fails: > > regression=# select '3'::jsonb || '{}'::jsonb; > > ERROR: invalid concatenation of jsonb objects > > I wonder what is the point of this weird exception, and whether >

Re: Weird special case in jsonb_concat()

2020-12-19 Thread Tom Lane
I wrote: > However, further experimentation found a case that fails: > regression=# select '3'::jsonb || '{}'::jsonb; > ERROR: invalid concatenation of jsonb objects > I wonder what is the point of this weird exception, and whether > whoever devised it can provide a concise explanation of what > t

Weird special case in jsonb_concat()

2020-12-18 Thread Tom Lane
The discussion in [1] pointed out that the existing documentation for the "jsonb || jsonb" concatenation operator is far short of reality: it fails to acknowledge that the operator will accept any cases other than two jsonb array inputs or two jsonb object inputs. I'd about concluded that other ca