Skip to content

Commit 9548417

Browse files
committed
list comprehension draft
1 parent e2a830b commit 9548417

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/backend/parser/cypher_gram.y

+34
Original file line numberDiff line numberDiff line change
@@ -18136,6 +18136,40 @@ list:
1813618136
$$ = (Node *)n;
1813718137

1813818138
}
18139+
| '[' ColId IN cypher_a_expr cypher_where_opt RETURN return_item ']' %prec '['
18140+
{
18141+
18142+
ereport(ERROR, errmsg("list comprehensions are not yet implemented"));
18143+
18144+
cypher_return *ret = make_ag_node(cypher_return);
18145+
ret->items = list_make1($7);
18146+
18147+
ResTarget *res = makeNode(ResTarget);
18148+
res->name = $2;
18149+
res->indirection = NIL;
18150+
res->val = (Node *)makeFuncCall(list_make2(makeString("postgraph"), makeString("collect")), list_make1($4), COERCE_SQL_SYNTAX, @4);
18151+
res->location = @4;
18152+
18153+
cypher_unwind *unwind = make_ag_node(cypher_unwind);
18154+
unwind->target = res;
18155+
unwind->where = $5;
18156+
18157+
List *pattern = list_make2(unwind, ret);
18158+
cypher_sub_pattern *sub;
18159+
18160+
sub = make_ag_node(cypher_sub_pattern);
18161+
sub->pattern = pattern;
18162+
sub->kind = CSP_EXISTS;
18163+
18164+
SubLink *n = makeNode(SubLink);
18165+
n->subLinkType = EXPR_SUBLINK;
18166+
n->subLinkId = 0;
18167+
n->testexpr = NULL;
18168+
n->operName = NIL;
18169+
n->subselect = sub;
18170+
n->location = @1;
18171+
$$ = (Node *)n;
18172+
}
1813918173
/*| '[' ColId IN cypher_a_expr cypher_where_opt '|' return_item ']' %prec '['
1814018174
{
1814118175
ereport(ERROR, errmsg("list comprehensions are not yet implemented"));

0 commit comments

Comments
 (0)