@> operator tests
authorMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 18:45:43 +0000 (10:45 -0800)
committerMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 18:45:43 +0000 (10:45 -0800)
contrib/hstore/sql/hstore.sql
src/test/regress/expected/jsonb.out
src/test/regress/sql/jsonb.sql

index c8166b55eaecbfbd9ea1c7440cdad687a9bc921a..982de63296b4c503ac2ede91415356e510b73c50 100644 (file)
@@ -273,15 +273,6 @@ select * from svals('');
 
 select * from each('aaa=>bq, b=>NULL, ""=>1 ');
 
--- @>
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, g=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'g=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>c';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
-select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>q';
-
 -- json
 select hstore_to_json('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
 select cast( hstore  '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as json);
index 37bd67aaccf1396548fafd4d4a4a95bc97502183..47244a8ce76c01cf040f187bc9fd512895559383 100644 (file)
@@ -301,6 +301,50 @@ select array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
  [{"a": 1},{"b": [2, 3]}]
 (1 row)
 
+-- operators
+-- @>
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}';
+ ?column? 
+----------
+ t
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":null}';
+ ?column? 
+----------
+ t
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "g":null}';
+ ?column? 
+----------
+ f
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"g":null}';
+ ?column? 
+----------
+ f
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"c"}';
+ ?column? 
+----------
+ f
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}';
+ ?column? 
+----------
+ t
+(1 row)
+
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":"q"}';
+ ?column? 
+----------
+ f
+(1 row)
+
 -- jsonb extraction functions
 CREATE TEMP TABLE test_jsonb (
        json_type text,
index 7f5280278dfb743003cdc12dc28772b5d02cf77b..3d2d7faea9c4697f027b533bcfba9714a0e80e23 100644 (file)
@@ -62,6 +62,16 @@ SELECT '    '::jsonb;            -- ERROR, no value
 -- make sure jsonb is passed through json generators without being escaped
 select array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
 
+-- operators
+
+-- @>
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":null}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "g":null}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"g":null}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"c"}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}';
+select '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":"q"}';
 
 -- jsonb extraction functions