Fix returning pattern comprehension and a property value.
This commit is contained in:
parent
c6cd2134a0
commit
9bb2050373
@ -684,9 +684,8 @@ static void ParseForeach(query::Foreach &foreach, SingleQueryPart &query_part, A
|
|||||||
|
|
||||||
static void ParseReturn(query::Return &ret, AstStorage &storage, SymbolTable &symbol_table,
|
static void ParseReturn(query::Return &ret, AstStorage &storage, SymbolTable &symbol_table,
|
||||||
std::unordered_map<std::string, PatternComprehensionMatching> &matchings) {
|
std::unordered_map<std::string, PatternComprehensionMatching> &matchings) {
|
||||||
PatternVisitor visitor(symbol_table, storage);
|
|
||||||
|
|
||||||
for (auto *expr : ret.body_.named_expressions) {
|
for (auto *expr : ret.body_.named_expressions) {
|
||||||
|
PatternVisitor visitor(symbol_table, storage);
|
||||||
expr->Accept(visitor);
|
expr->Accept(visitor);
|
||||||
auto pattern_comprehension_matchings = visitor.getPatternComprehensionMatchings();
|
auto pattern_comprehension_matchings = visitor.getPatternComprehensionMatchings();
|
||||||
for (auto &matching : pattern_comprehension_matchings) {
|
for (auto &matching : pattern_comprehension_matchings) {
|
||||||
|
@ -59,13 +59,10 @@ class ReturnBodyContext : public HierarchicalTreeVisitor {
|
|||||||
named_expressions_.emplace_back(named_expr);
|
named_expressions_.emplace_back(named_expr);
|
||||||
|
|
||||||
// Pattern comprehension can be filled during named expression traversion
|
// Pattern comprehension can be filled during named expression traversion
|
||||||
if (has_pattern_comprehension()) {
|
if (auto it = pc_ops.find(named_expr->name_); it != pc_ops.end()) {
|
||||||
if (auto it = pc_ops.find(named_expr->name_); it != pc_ops.end()) {
|
MG_ASSERT(pattern_comprehension_data_.pattern_comprehension != nullptr);
|
||||||
pattern_comprehension_data_.op = std::move(it->second.op);
|
pattern_comprehension_data_.op = std::move(it->second.op);
|
||||||
pc_ops.erase(it);
|
pc_ops.erase(it);
|
||||||
} else {
|
|
||||||
throw utils::NotYetImplemented("Operation on top of pattern comprehension");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Collect symbols used in group by expressions.
|
// Collect symbols used in group by expressions.
|
||||||
|
@ -302,6 +302,17 @@ Feature: List operators
|
|||||||
| years | keanu.name |
|
| years | keanu.name |
|
||||||
| [2003, 2003, 1999, 2021] | "Keanu Reeves" |
|
| [2003, 2003, 1999, 2021] | "Keanu Reeves" |
|
||||||
|
|
||||||
|
Scenario: List pattern comprehension and property
|
||||||
|
Given graph "graph_keanu"
|
||||||
|
When executing query:
|
||||||
|
"""
|
||||||
|
MATCH (keanu:Person {name: 'Keanu Reeves'})
|
||||||
|
RETURN [(keanu)-->(b:Movie) WHERE b.title CONTAINS 'Matrix' | size(b.title)] AS movie_lens;
|
||||||
|
"""
|
||||||
|
Then the result should be:
|
||||||
|
| movie_lens |
|
||||||
|
| [22, 19, 10, 24] |
|
||||||
|
|
||||||
Scenario: Multiple entries with list pattern comprehension
|
Scenario: Multiple entries with list pattern comprehension
|
||||||
Given graph "graph_keanu"
|
Given graph "graph_keanu"
|
||||||
When executing query:
|
When executing query:
|
||||||
|
Loading…
Reference in New Issue
Block a user