Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/query/plan/preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,15 @@ void PatternVisitor::Visit(NamedExpression &op) { op.expression_->Accept(*this);
void PatternVisitor::Visit(PatternComprehension &op) {
PatternComprehensionMatching matching;
AddMatching({op.pattern_}, op.filter_, symbol_table_, storage_, matching);

for (auto &filter : matching.filters) {
PatternVisitor nested_visitor(symbol_table_, storage_);

filter.expression->Accept(nested_visitor);
filter.matchings = nested_visitor.getFilterMatchings();
filter.pattern_comprehension_matchings = nested_visitor.getPatternComprehensionMatchings();
}

matching.result_expr = storage_.Create<NamedExpression>(symbol_table_.at(op).name(), op.resultExpr_);
matching.result_expr->MapTo(symbol_table_.at(op));
matching.result_symbol = symbol_table_.at(op);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,19 @@ Feature: ListComprehension
MATCH (a) WHERE single(x in [(a)-[:R]->(b) WHERE b is null | 1] WHERE true) RETURN a.id AS id
"""
Then the result should be empty

Scenario: Pattern comprehension in list comprehension - double nested
Given an empty graph
And having executed:
"""
CREATE (a:A {id: 1})<-[:R1]-(:B)<-[:R2]-(:C)<-[:R3]-(:D {id: 1});
"""
When executing query:
"""
MATCH (a:A)
WHERE single(b IN [(a)<-[:R1]-(b:B) WHERE single(c IN [(b)<-[:R2]-(c:C) WHERE single(d IN [(c)<-[:R3]-(d:D) WHERE d.id = 1 | 1] WHERE true) | 1] WHERE true) | 1] WHERE true)
RETURN a.id AS id;
"""
Then the result should be:
| id |
| 1 |
Loading