@@ -6398,8 +6398,8 @@ SELECT * FROM cypher('case_statement', $$
63986398 WHEN 1 THEN count(*)
63996399 ELSE 'not count'
64006400 END
6401- $$ ) AS (j agtype, case_statement agtype);
6402- j | case_statement
6401+ $$ ) AS (n agtype, case_statement agtype);
6402+ n | case_statement
64036403------------------------------------------------------------------------------------------------+----------------
64046404 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64056405 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6416,8 +6416,8 @@ SELECT * FROM cypher('case_statement', $$
64166416 WHEN 1 THEN count(*)
64176417 ELSE 'not count'
64186418 END
6419- $$ ) AS (j agtype, case_statement agtype);
6420- j | case_statement
6419+ $$ ) AS (n agtype, case_statement agtype);
6420+ n | case_statement
64216421------------------------------------------------------------------------------------------------+----------------
64226422 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64236423 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6434,8 +6434,8 @@ SELECT * FROM cypher('case_statement', $$
64346434 WHEN 1 THEN count(n)
64356435 ELSE 'not count'
64366436 END
6437- $$ ) AS (j agtype, case_statement agtype);
6438- j | case_statement
6437+ $$ ) AS (n agtype, case_statement agtype);
6438+ n | case_statement
64396439------------------------------------------------------------------------------------------------+----------------
64406440 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64416441 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6452,8 +6452,8 @@ SELECT * FROM cypher('case_statement', $$
64526452 WHEN 1 THEN count(n)
64536453 ELSE 'not count'
64546454 END
6455- $$ ) AS (j agtype, case_statement agtype);
6456- j | case_statement
6455+ $$ ) AS (n agtype, case_statement agtype);
6456+ n | case_statement
64576457------------------------------------------------------------------------------------------------+----------------
64586458 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64596459 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6470,8 +6470,8 @@ SELECT * FROM cypher('case_statement', $$
64706470 WHEN 1 THEN count(1)
64716471 ELSE 'not count'
64726472 END
6473- $$ ) AS (j agtype, case_statement agtype);
6474- j | case_statement
6473+ $$ ) AS (n agtype, case_statement agtype);
6474+ n | case_statement
64756475------------------------------------------------------------------------------------------------+----------------
64766476 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64776477 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6488,8 +6488,8 @@ SELECT * FROM cypher('case_statement', $$
64886488 WHEN 1 THEN count(1)
64896489 ELSE 'not count'
64906490 END
6491- $$ ) AS (j agtype, case_statement agtype);
6492- j | case_statement
6491+ $$ ) AS (n agtype, case_statement agtype);
6492+ n | case_statement
64936493------------------------------------------------------------------------------------------------+----------------
64946494 {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "not count"
64956495 {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "not count"
@@ -6499,6 +6499,72 @@ $$ ) AS (j agtype, case_statement agtype);
64996499 {"id": 281474976710662, "label": "", "properties": {"i": {}, "j": {"i": 1}, "id": 6}}::vertex | "not count"
65006500(6 rows)
65016501
6502+ --CASE with EXISTS()
6503+ --exists(n.property)
6504+ SELECT * FROM cypher('case_statement', $$
6505+ MATCH (n)
6506+ RETURN n, CASE exists(n.j)
6507+ WHEN true THEN 'property j exists'
6508+ ELSE 'property j does not exist'
6509+ END
6510+ $$ ) AS (n agtype, case_statement agtype);
6511+ n | case_statement
6512+ ------------------------------------------------------------------------------------------------+-----------------------------
6513+ {"id": 281474976710657, "label": "", "properties": {"i": 1, "id": 1}}::vertex | "property j does not exist"
6514+ {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "property j exists"
6515+ {"id": 281474976710659, "label": "", "properties": {"i": 0, "j": 1, "id": 3}}::vertex | "property j exists"
6516+ {"id": 281474976710660, "label": "", "properties": {"i": true, "j": false, "id": 4}}::vertex | "property j exists"
6517+ {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "property j exists"
6518+ {"id": 281474976710662, "label": "", "properties": {"i": {}, "j": {"i": 1}, "id": 6}}::vertex | "property j exists"
6519+ (6 rows)
6520+
6521+ --CASE evaluates to boolean true, is not a boolean, should hit ELSE
6522+ SELECT * FROM cypher('case_statement', $$
6523+ MATCH (n)
6524+ RETURN n, CASE exists(n.j)
6525+ WHEN 1 THEN 'should not output me'
6526+ ELSE '1 is not a boolean'
6527+ END
6528+ $$ ) AS (n agtype, case_statement agtype);
6529+ n | case_statement
6530+ ------------------------------------------------------------------------------------------------+----------------------
6531+ {"id": 281474976710657, "label": "", "properties": {"i": 1, "id": 1}}::vertex | "1 is not a boolean"
6532+ {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "1 is not a boolean"
6533+ {"id": 281474976710659, "label": "", "properties": {"i": 0, "j": 1, "id": 3}}::vertex | "1 is not a boolean"
6534+ {"id": 281474976710660, "label": "", "properties": {"i": true, "j": false, "id": 4}}::vertex | "1 is not a boolean"
6535+ {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "1 is not a boolean"
6536+ {"id": 281474976710662, "label": "", "properties": {"i": {}, "j": {"i": 1}, "id": 6}}::vertex | "1 is not a boolean"
6537+ (6 rows)
6538+
6539+ --exists in WHEN, vacuously false because exists(n.j) evaluates to a boolean, n is a vertex
6540+ SELECT * FROM cypher('case_statement', $$
6541+ MATCH (n)
6542+ RETURN n, CASE n
6543+ WHEN exists(n.j) THEN 'should not output me'
6544+ ELSE 'n is a vertex, not a boolean'
6545+ END
6546+ $$ ) AS (j agtype, case_statement agtype);
6547+ j | case_statement
6548+ ------------------------------------------------------------------------------------------------+--------------------------------
6549+ {"id": 281474976710657, "label": "", "properties": {"i": 1, "id": 1}}::vertex | "n is a vertex, not a boolean"
6550+ {"id": 281474976710658, "label": "", "properties": {"i": "a", "j": "b", "id": 2}}::vertex | "n is a vertex, not a boolean"
6551+ {"id": 281474976710659, "label": "", "properties": {"i": 0, "j": 1, "id": 3}}::vertex | "n is a vertex, not a boolean"
6552+ {"id": 281474976710660, "label": "", "properties": {"i": true, "j": false, "id": 4}}::vertex | "n is a vertex, not a boolean"
6553+ {"id": 281474976710661, "label": "", "properties": {"i": [], "j": [0, 1, 2], "id": 5}}::vertex | "n is a vertex, not a boolean"
6554+ {"id": 281474976710662, "label": "", "properties": {"i": {}, "j": {"i": 1}, "id": 6}}::vertex | "n is a vertex, not a boolean"
6555+ (6 rows)
6556+
6557+ --exists(*) (should fail)
6558+ SELECT * FROM cypher('case_statement', $$
6559+ MATCH (n)
6560+ RETURN n, CASE n.j
6561+ WHEN 1 THEN exists(*)
6562+ ELSE 'not count'
6563+ END
6564+ $$ ) AS (j agtype, case_statement agtype);
6565+ ERROR: syntax error at or near "*"
6566+ LINE 4: WHEN 1 THEN exists(*)
6567+ ^
65026568-- RETURN * and (u)--(v) optional forms
65036569SELECT create_graph('opt_forms');
65046570NOTICE: graph "opt_forms" has been created
0 commit comments