Throw when reduce inside exists (#1392)
This commit is contained in:
parent
5e6c5618f5
commit
fdbc390d53
@ -480,12 +480,20 @@ bool SymbolGenerator::PreVisit(None &none) {
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PreVisit(Reduce &reduce) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_reduce = true;
|
||||
reduce.initializer_->Accept(*this);
|
||||
reduce.list_->Accept(*this);
|
||||
VisitWithIdentifiers(reduce.expression_, {reduce.accumulator_, reduce.identifier_});
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PostVisit(Reduce & /*reduce*/) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_reduce = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PreVisit(Extract &extract) {
|
||||
extract.list_->Accept(*this);
|
||||
VisitWithIdentifiers(extract.expression_, {extract.identifier_});
|
||||
@ -496,15 +504,19 @@ bool SymbolGenerator::PreVisit(Exists &exists) {
|
||||
auto &scope = scopes_.back();
|
||||
|
||||
if (scope.in_set_property) {
|
||||
throw utils::NotYetImplemented("Set property can not be used with exists, but only during matching!");
|
||||
throw utils::NotYetImplemented("Exists cannot be used within SET clause.!");
|
||||
}
|
||||
|
||||
if (scope.in_with) {
|
||||
throw utils::NotYetImplemented("WITH can not be used with exists, but only during matching!");
|
||||
throw utils::NotYetImplemented("Exists cannot be used within WITH!");
|
||||
}
|
||||
|
||||
if (scope.in_return) {
|
||||
throw utils::NotYetImplemented("RETURN can not be used with exists, but only during matching!");
|
||||
throw utils::NotYetImplemented("Exists cannot be used within RETURN!");
|
||||
}
|
||||
|
||||
if (scope.in_reduce) {
|
||||
throw utils::NotYetImplemented("Exists cannot be used within REDUCE!");
|
||||
}
|
||||
|
||||
if (scope.num_if_operators) {
|
||||
|
@ -84,6 +84,7 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
bool PreVisit(Any &) override;
|
||||
bool PreVisit(None &) override;
|
||||
bool PreVisit(Reduce &) override;
|
||||
bool PostVisit(Reduce &) override;
|
||||
bool PreVisit(Extract &) override;
|
||||
bool PreVisit(Exists & /*exists*/) override;
|
||||
bool PostVisit(Exists & /*exists*/) override;
|
||||
@ -123,6 +124,7 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
bool in_match{false};
|
||||
bool in_foreach{false};
|
||||
bool in_exists{false};
|
||||
bool in_reduce{false};
|
||||
bool in_set_property{false};
|
||||
bool in_call_subquery{false};
|
||||
bool has_return{false};
|
||||
|
@ -1158,3 +1158,15 @@ Feature: Functions
|
||||
Then the result should be:
|
||||
| A_COUNT | B_COUNT |
|
||||
| 3 | 15 |
|
||||
|
||||
Scenario: Exists is forbidden within reduce:
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
"""
|
||||
CREATE ()
|
||||
"""
|
||||
When executing query:
|
||||
"""
|
||||
MATCH () WHERE reduce(a=exists(()),b in []|a) RETURN 1;
|
||||
"""
|
||||
Then an error should be raised
|
||||
|
Loading…
Reference in New Issue
Block a user