mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
docs: Map operator @> to the proper SGML escape for '>'
Backpatch through 9.5
This commit is contained in:
parent
b852dc4cbd
commit
23d29cef93
@ -267,30 +267,30 @@ SELECT '{"reading": 1.230e-5}'::json, '{"reading": 1.230e-5}'::jsonb;
|
|||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
-- Simple scalar/primitive values contain only the identical value:
|
-- Simple scalar/primitive values contain only the identical value:
|
||||||
SELECT '"foo"'::jsonb @> '"foo"'::jsonb;
|
SELECT '"foo"'::jsonb @> '"foo"'::jsonb;
|
||||||
|
|
||||||
-- The array on the right side is contained within the one on the left:
|
-- The array on the right side is contained within the one on the left:
|
||||||
SELECT '[1, 2, 3]'::jsonb @> '[1, 3]'::jsonb;
|
SELECT '[1, 2, 3]'::jsonb @> '[1, 3]'::jsonb;
|
||||||
|
|
||||||
-- Order of array elements is not significant, so this is also true:
|
-- Order of array elements is not significant, so this is also true:
|
||||||
SELECT '[1, 2, 3]'::jsonb @> '[3, 1]'::jsonb;
|
SELECT '[1, 2, 3]'::jsonb @> '[3, 1]'::jsonb;
|
||||||
|
|
||||||
-- Duplicate array elements don't matter either:
|
-- Duplicate array elements don't matter either:
|
||||||
SELECT '[1, 2, 3]'::jsonb @> '[1, 2, 2]'::jsonb;
|
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:
|
||||||
SELECT '[1, 2, [1, 3]]'::jsonb @> '[1, 3]'::jsonb; -- yields false
|
SELECT '[1, 2, [1, 3]]'::jsonb @> '[1, 3]'::jsonb; -- yields false
|
||||||
|
|
||||||
-- But with a layer of nesting, it is contained:
|
-- But with a layer of nesting, it is contained:
|
||||||
SELECT '[1, 2, [1, 3]]'::jsonb @> '[[1, 3]]'::jsonb;
|
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
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -309,10 +309,10 @@ SELECT '{"foo": {"bar": "baz"}}'::jsonb @> '{"bar": "baz"}'::jsonb; -- yields f
|
|||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
-- This array contains the primitive string value:
|
-- This array contains the primitive string value:
|
||||||
SELECT '["foo", "bar"]'::jsonb @> '"bar"'::jsonb;
|
SELECT '["foo", "bar"]'::jsonb @> '"bar"'::jsonb;
|
||||||
|
|
||||||
-- This exception is not reciprocal -- non-containment is reported here:
|
-- This exception is not reciprocal -- non-containment is reported here:
|
||||||
SELECT '"bar"'::jsonb @> '["bar"]'::jsonb; -- yields false
|
SELECT '"bar"'::jsonb @> '["bar"]'::jsonb; -- yields false
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -79,7 +79,7 @@ INSERT INTO reservation VALUES
|
|||||||
(1108, '[2010-01-01 14:30, 2010-01-01 15:30)');
|
(1108, '[2010-01-01 14:30, 2010-01-01 15:30)');
|
||||||
|
|
||||||
-- Containment
|
-- Containment
|
||||||
SELECT int4range(10, 20) @> 3;
|
SELECT int4range(10, 20) @> 3;
|
||||||
|
|
||||||
-- Overlaps
|
-- Overlaps
|
||||||
SELECT numrange(11.1, 22.2) && numrange(20.0, 30.0);
|
SELECT numrange(11.1, 22.2) && numrange(20.0, 30.0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user