From 1d5f3f976b26271b51a619f02436ec5c263db9f3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 21 Dec 2020 13:11:30 -0500 Subject: Remove "invalid concatenation of jsonb objects" error case. The jsonb || jsonb operator arbitrarily rejected certain combinations of scalar and non-scalar inputs, while being willing to concatenate other combinations. This was of course quite undocumented. Rather than trying to document it, let's just remove the restriction, creating a uniform rule that unless we are handling an object-to-object concatenation, non-array inputs are converted to one-element arrays, resulting in an array-to-array concatenation. (This does not change the behavior for any case that didn't throw an error before.) Per complaint from Joel Jacobson. Back-patch to all supported branches. Discussion: https://postgr.es/m/163099.1608312033@sss.pgh.pa.us --- src/test/regress/sql/jsonb.sql | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/test/regress/sql/jsonb.sql') diff --git a/src/test/regress/sql/jsonb.sql b/src/test/regress/sql/jsonb.sql index 4c195b5527a..f1539682abd 100644 --- a/src/test/regress/sql/jsonb.sql +++ b/src/test/regress/sql/jsonb.sql @@ -772,6 +772,11 @@ select '{"a":"b"}'::jsonb || '[]'::jsonb; select '"a"'::jsonb || '{"a":1}'; select '{"a":1}' || '"a"'::jsonb; +select '[3]'::jsonb || '{}'::jsonb; +select '3'::jsonb || '[]'::jsonb; +select '3'::jsonb || '4'::jsonb; +select '3'::jsonb || '{}'::jsonb; + select '["a", "b"]'::jsonb || '{"c":1}'; select '{"c": 1}'::jsonb || '["a", "b"]'; -- cgit v1.2.3