@@ -617,6 +617,53 @@ SELECT * FROM cypher('list_comprehension', $$ MATCH (u) WITH *, [i in [1,2,3]] a
617
617
[1, 2, 3]
618
618
(1 row)
619
619
620
+ -- Issue 1955 - variable reference in list comprehension
621
+ SELECT * FROM cypher('list_comprehension', $$ MATCH (u) WHERE u.list=[i IN u.list] RETURN u $$) AS (result agtype);
622
+ result
623
+ ---------------------------------------------------------------------------------------------------------------------------------------------------------------
624
+ {"id": 281474976710658, "label": "", "properties": {"list": [1, 3, 5, 7, 9, 11, 13]}}::vertex
625
+ {"id": 281474976710660, "label": "", "properties": {"list": [12, 14, 16, 18, 20, 22, 24]}}::vertex
626
+ {"id": 281474976710662, "label": "", "properties": {"list": [25.0, 49.0, 81.0, 121.0, 169.0]}}::vertex
627
+ {"id": 281474976710657, "label": "", "properties": {"a": [], "b": [0, 1, 2, 3, 4, 5], "c": [0, 2, 4, 6, 8, 10, 12], "list": [0, 2, 4, 6, 8, 10, 12]}}::vertex
628
+ {"id": 281474976710663, "label": "", "properties": {"list": [1, 2, 3]}}::vertex
629
+ {"id": 281474976710659, "label": "", "properties": {"list": []}}::vertex
630
+ {"id": 281474976710661, "label": "", "properties": {"list": [6, 8, 10, 12]}}::vertex
631
+ {"id": 844424930131969, "label": "csm_match", "properties": {"list": ["abc", "def", "ghi"]}}::vertex
632
+ (8 rows)
633
+
634
+ SELECT * FROM cypher('list_comprehension', $$ MATCH (u) WHERE u.list=[i IN u.list WHERE i>0] RETURN u $$) AS (result agtype);
635
+ result
636
+ --------------------------------------------------------------------------------------------------------
637
+ {"id": 281474976710658, "label": "", "properties": {"list": [1, 3, 5, 7, 9, 11, 13]}}::vertex
638
+ {"id": 281474976710660, "label": "", "properties": {"list": [12, 14, 16, 18, 20, 22, 24]}}::vertex
639
+ {"id": 281474976710662, "label": "", "properties": {"list": [25.0, 49.0, 81.0, 121.0, 169.0]}}::vertex
640
+ {"id": 281474976710663, "label": "", "properties": {"list": [1, 2, 3]}}::vertex
641
+ {"id": 281474976710661, "label": "", "properties": {"list": [6, 8, 10, 12]}}::vertex
642
+ (5 rows)
643
+
644
+ SELECT * FROM cypher('list_comprehension', $$ MATCH (u) WHERE size([e in u.list where e starts with "a"])>0 RETURN u $$) AS (result agtype);
645
+ result
646
+ ------------------------------------------------------------------------------------------------------
647
+ {"id": 844424930131969, "label": "csm_match", "properties": {"list": ["abc", "def", "ghi"]}}::vertex
648
+ (1 row)
649
+
650
+ SELECT * FROM cypher('list_comprehension', $$ MATCH (u ={list:[i IN u.list | i+1]}) RETURN u $$) AS (result agtype);
651
+ result
652
+ --------------------------------------------------------------------------
653
+ {"id": 281474976710659, "label": "", "properties": {"list": []}}::vertex
654
+ (1 row)
655
+
656
+ SELECT * FROM cypher('list_comprehension', $$ MATCH (u ={list:[i IN u.list WHERE i>0]}) RETURN u$$) AS (result agtype);
657
+ result
658
+ --------------------------------------------------------------------------------------------------------
659
+ {"id": 281474976710658, "label": "", "properties": {"list": [1, 3, 5, 7, 9, 11, 13]}}::vertex
660
+ {"id": 281474976710660, "label": "", "properties": {"list": [12, 14, 16, 18, 20, 22, 24]}}::vertex
661
+ {"id": 281474976710662, "label": "", "properties": {"list": [25.0, 49.0, 81.0, 121.0, 169.0]}}::vertex
662
+ {"id": 281474976710663, "label": "", "properties": {"list": [1, 2, 3]}}::vertex
663
+ {"id": 281474976710661, "label": "", "properties": {"list": [6, 8, 10, 12]}}::vertex
664
+ (5 rows)
665
+
666
+ -- Clean up
620
667
SELECT * FROM drop_graph('list_comprehension', true);
621
668
NOTICE: drop cascades to 4 other objects
622
669
DETAIL: drop cascades to table list_comprehension._ag_label_vertex
0 commit comments