jsonb exists tests
authorMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 23:36:26 +0000 (15:36 -0800)
committerMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 23:36:26 +0000 (15:36 -0800)
contrib/hstore/sql/nested.sql
src/test/regress/expected/jsonb.out
src/test/regress/sql/jsonb.sql

index 68c4c8e81fab5b3fd428d31dbe031a0c2df71993..4e1b40b93002fe931f49b4bdd10348b2a75430a2 100644 (file)
@@ -125,55 +125,6 @@ SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #%> '{3}';
 SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #%> '{4}';
 SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #%> '{4,5}';
 
--- ?
-
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 5;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 4;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 3;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 2;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 1;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? 0;
-
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 5;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 4;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 3;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 2;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 1;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? 0;
-
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -6;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -5;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -4;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -3;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -2;
-SELECT 'n=>NULL, a=>1, b=>{1,2}, c=>{1=>2}, d=>{1=>{2,3}}'::hstore ? -1;
-
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -6;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -5;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -4;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -3;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -2;
-SELECT '[a,b, c,{1,2}, NULL]'::hstore ? -1;
-
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{0}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{a}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{b}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, 0}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, 1}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, 2}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, 3}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, -1}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, -2}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, -3}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, -4}'::text[];
-SELECT 'a=>b, c=>{1,2,3}'::hstore #? '{c, -5}'::text[];
-
-SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #? '{0}'::text[];
-SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #? '{3}'::text[];
-SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #? '{4}'::text[];
-SELECT '[0, 1, 2, {3,4}, {5=>five}]'::hstore #? '{4,5}'::text[];
-
 --deep delete
 
 SELECT 'a=>1'::hstore #- '{x}';
index c2b24bbf7cc418e2d35d25b7c0f5948991cd56cb..a5506e28c8e2a97cbb66a4199db167bd97a86264 100644 (file)
@@ -1876,3 +1876,40 @@ SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4,5}';
  "five"
 (1 row)
 
+--nested exists
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'n';
+ ?column? 
+----------
+ t
+(1 row)
+
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'a';
+ ?column? 
+----------
+ t
+(1 row)
+
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'b';
+ ?column? 
+----------
+ t
+(1 row)
+
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'c';
+ ?column? 
+----------
+ t
+(1 row)
+
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'd';
+ ?column? 
+----------
+ t
+(1 row)
+
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'e';
+ ?column? 
+----------
+ f
+(1 row)
+
index b4d5b146a3086606ad1b1071fee29ab140cf88fc..d7f70b0783fd49c885d56ec939293cfce7bb63d3 100644 (file)
@@ -467,3 +467,11 @@ SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{0}';
 SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{3}';
 SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4}';
 SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4,5}';
+
+--nested exists
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'n';
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'a';
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'b';
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'c';
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'd';
+SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'e';