Skip to content

Commit 51fb7c3

Browse files
committed
Fix Property Constraints
1 parent def1a00 commit 51fb7c3

File tree

2 files changed

+88
-35
lines changed

2 files changed

+88
-35
lines changed

regress/expected/cypher_match.out

+87-34
Original file line numberDiff line numberDiff line change
@@ -328,23 +328,38 @@ CREATE ({lst: [1, NULL, 3.14, 'string', {key: 'value'}, []]});
328328
(0 rows)
329329

330330
MATCH (n {string_key: NULL}) RETURN n;
331-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
332-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
331+
n
332+
---
333+
(0 rows)
334+
333335
MATCH (n {string_key: 'wrong value'}) RETURN n ;
334-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
335-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
336+
n
337+
---
338+
(0 rows)
339+
336340
MATCH (n {string_key: 'test', int_key: 1, float_key: 3.14, map_key: {key: 'value'}, list_key: [1, 2, 3]}) RETURN n;
337-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
338-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
341+
n
342+
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
343+
{"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}
344+
(1 row)
345+
339346
MATCH (n {string_key: 'test'}) RETURN n;
340-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
341-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
347+
n
348+
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
349+
{"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}
350+
(1 row)
351+
342352
MATCH (n {lst: [1, NULL, 3.14, 'string', {key: 'value'}, []]}) RETURN n;
343-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
344-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
353+
n
354+
--------------------------------------------------------------------------------------------------------------
355+
{"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}
356+
(1 row)
357+
345358
MATCH (n {lst: [1, NULL, 3.14, 'string', {key: 'value'}, [], 'extra value']}) RETURN n;
346-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
347-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
359+
n
360+
---
361+
(0 rows)
362+
348363
-- Path of one vertex.
349364
MATCH p=() RETURN p;
350365
p
@@ -392,14 +407,23 @@ MATCH (u)-[e]->(v) WHERE EXISTS ((u)-[e]->(v)) RETURN u, e, v;
392407

393408
-- Property Constraint in EXISTS
394409
MATCH (u) WHERE EXISTS((u)-[]->({id: 'middle'})) RETURN u;
395-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
396-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
410+
u
411+
--------------------------------------------------------------------------
412+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
413+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
414+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
415+
(3 rows)
416+
397417
MATCH (u) WHERE EXISTS((u)-[]->({id: 'not a valid id'})) RETURN u;
398-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
399-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
418+
u
419+
---
420+
(0 rows)
421+
400422
MATCH (u) WHERE EXISTS((u)-[]->({id: NULL})) RETURN u;
401-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
402-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
423+
u
424+
---
425+
(0 rows)
426+
403427
-- Exists checks for a loop. There shouldn't be any.
404428
MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(u)) RETURN u, e, v;
405429
u | e | v
@@ -465,11 +489,21 @@ MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(x)) RETURN u, e, v;
465489
(7 rows)
466490

467491
MATCH (u) WHERE EXISTS(MATCH (u)-[]->({id: 'middle'}) RETURN 1) RETURN u;
468-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
469-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
492+
u
493+
--------------------------------------------------------------------------
494+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
495+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
496+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
497+
(3 rows)
498+
470499
MATCH (u) WHERE EXISTS(MATCH (u)-[]->({id: 'middle'}) RETURN u) RETURN u;
471-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
472-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
500+
u
501+
--------------------------------------------------------------------------
502+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
503+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
504+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
505+
(3 rows)
506+
473507
MATCH (u) WHERE u.id = ANY (MATCH (v) RETURN v.id) RETURN u;
474508
u
475509
----------------------------------------------------------------------------
@@ -521,20 +555,36 @@ RETURN u;
521555
(3 rows)
522556

523557
MATCH (u) WHERE EXISTS(MATCH (u)-[]->({id: 'gsjka'}) RETURN 1) RETURN u;
524-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
525-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
558+
u
559+
---
560+
(0 rows)
561+
526562
MATCH (u) WHERE EXISTS(MATCH (v {id: 'middle'}) MATCH (u)-[]->(v) RETURN 1) RETURN u;
527-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
528-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
563+
u
564+
--------------------------------------------------------------------------
565+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
566+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
567+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
568+
(3 rows)
569+
529570
MATCH (u) WHERE EXISTS(MATCH (v {id: 'middle'}) MATCH (u)-[]->(v) RETURN 1) RETURN u;
530-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
531-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
571+
u
572+
--------------------------------------------------------------------------
573+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
574+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
575+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
576+
(3 rows)
577+
532578
MATCH (u) WHERE EXISTS(MATCH (u)-[]->(v {id: 'middle'}) RETURN 1) RETURN u;
533-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
534-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
579+
u
580+
--------------------------------------------------------------------------
581+
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}
582+
{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}
583+
{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}
584+
(3 rows)
585+
535586
MATCH (u) RETURN case WHEN EXISTS(MATCH (u)-[]->({id: 'gsjka'}) RETURN 1) THEN 1 ELSE 2 END;
536-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
537-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
587+
ERROR: cannot handle unplanned sub-select
538588
MATCH (u) RETURN case WHEN EXISTS(MATCH (u)-[]->() RETURN 1) THEN 1 ELSE 2 END;
539589
ERROR: cannot handle unplanned sub-select
540590

@@ -1300,8 +1350,11 @@ CREATE ({i: 1, j: 2, k: 3}), ({i: 1, j: 3}), ({i:2, k: 3});
13001350
(0 rows)
13011351

13021352
MATCH (n {j: 2}) WHERE n.i = 1 RETURN n;
1303-
ERROR: operator does not exist: postgraph.gtype @> postgraph.gtype
1304-
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
1353+
n
1354+
------------------------------------------------------------------------------
1355+
{"id": 281474976710662, "label": "", "properties": {"i": 1, "j": 2, "k": 3}}
1356+
(1 row)
1357+
13051358
--
13061359
-- Prepared Statement Property Constraint
13071360
--

src/backend/parser/cypher_clause.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3282,7 +3282,7 @@ static Node *create_property_constraints(cypher_parsestate *cpstate, transform_e
32823282
// use cypher to get the constraints' transform node
32833283
const_expr = transform_cypher_expr(cpstate, property_constraints, EXPR_KIND_WHERE);
32843284

3285-
return (Node *)make_op(pstate, list_make1(makeString("@>")), prop_expr, const_expr, last_srf, -1);
3285+
return (Node *)make_op(pstate, list_make2(makeString("postgraph"), makeString("@>")), prop_expr, const_expr, last_srf, -1);
32863286
}
32873287

32883288

0 commit comments

Comments
 (0)