mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
docs: add JSONB containment example of a key and empty object
Backpatch through 9.5
This commit is contained in:
parent
9445a1cd3c
commit
c86555fc80
@ -280,7 +280,7 @@ SELECT '[1, 2, 3]'::jsonb @> '[1, 2, 2]'::jsonb;
|
|||||||
|
|
||||||
-- The object with a single pair on the right side is contained
|
-- The object with a single pair on the right side is contained
|
||||||
-- within the object on the left side:
|
-- within the object on the left side:
|
||||||
SELECT '{"product": "PostgreSQL", "version": 9.4, "jsonb":true}'::jsonb @> '{"version":9.4}'::jsonb;
|
SELECT '{"product": "PostgreSQL", "version": 9.4, "jsonb": true}'::jsonb @> '{"version": 9.4}'::jsonb;
|
||||||
|
|
||||||
-- The array on the right side is <emphasis>not</> considered contained within the
|
-- The array on the right side is <emphasis>not</> considered contained within the
|
||||||
-- array on the left, even though a similar array is nested within it:
|
-- array on the left, even though a similar array is nested within it:
|
||||||
@ -291,6 +291,9 @@ SELECT '[1, 2, [1, 3]]'::jsonb @> '[[1, 3]]'::jsonb;
|
|||||||
|
|
||||||
-- Similarly, containment is not reported here:
|
-- Similarly, containment is not reported here:
|
||||||
SELECT '{"foo": {"bar": "baz"}}'::jsonb @> '{"bar": "baz"}'::jsonb; -- yields false
|
SELECT '{"foo": {"bar": "baz"}}'::jsonb @> '{"bar": "baz"}'::jsonb; -- yields false
|
||||||
|
|
||||||
|
-- A top-level key and an empty object is contained:
|
||||||
|
SELECT '{"foo": {"bar": "baz"}}'::jsonb @> '{"foo": {}}'::jsonb;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user