Skip to content

Commit c86555f

Browse files
committed
docs: add JSONB containment example of a key and empty object
Backpatch through 9.5
1 parent 9445a1c commit c86555f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/src/sgml/json.sgml

+4-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ SELECT '[1, 2, 3]'::jsonb @> '[1, 2, 2]'::jsonb;
280280

281281
-- The object with a single pair on the right side is contained
282282
-- within the object on the left side:
283-
SELECT '{"product": "PostgreSQL", "version": 9.4, "jsonb":true}'::jsonb @> '{"version":9.4}'::jsonb;
283+
SELECT '{"product": "PostgreSQL", "version": 9.4, "jsonb": true}'::jsonb @> '{"version": 9.4}'::jsonb;
284284

285285
-- The array on the right side is <emphasis>not</> considered contained within the
286286
-- array on the left, even though a similar array is nested within it:
@@ -291,6 +291,9 @@ SELECT '[1, 2, [1, 3]]'::jsonb @&gt; '[[1, 3]]'::jsonb;
291291

292292
-- Similarly, containment is not reported here:
293293
SELECT '{"foo": {"bar": "baz"}}'::jsonb @&gt; '{"bar": "baz"}'::jsonb; -- yields false
294+
295+
-- A top-level key and an empty object is contained:
296+
SELECT '{"foo": {"bar": "baz"}}'::jsonb @&gt; '{"foo": {}}'::jsonb;
294297
</programlisting>
295298

296299
<para>

0 commit comments

Comments
 (0)