Forbid merge with null properties
This commit is contained in:
parent
a282542666
commit
bfd8921777
@ -745,6 +745,14 @@ bool SymbolGenerator::PreVisit(PatternComprehension &pc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::Visit(PrimitiveLiteral &primitive_literal) {
|
||||
auto &scope = scopes_.back();
|
||||
if (scope.in_merge && primitive_literal.value_.IsNull()) {
|
||||
throw SemanticException("Cannot merge node or relationship entity because of null property value!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PostVisit(PatternComprehension & /*pc*/) { return true; }
|
||||
|
||||
void SymbolGenerator::VisitWithIdentifiers(Expression *expr, const std::vector<Identifier *> &identifiers) {
|
||||
|
@ -71,7 +71,7 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
|
||||
// Expressions
|
||||
ReturnType Visit(Identifier &) override;
|
||||
ReturnType Visit(PrimitiveLiteral &) override { return true; }
|
||||
ReturnType Visit(PrimitiveLiteral &) override;
|
||||
bool PreVisit(MapLiteral &) override;
|
||||
bool PostVisit(MapLiteral &) override { return true; };
|
||||
ReturnType Visit(ParameterLookup &) override { return true; }
|
||||
|
@ -187,7 +187,7 @@ Feature: Merge feature
|
||||
Then the result should be:
|
||||
| r |
|
||||
| [:X] |
|
||||
|
||||
|
||||
Scenario: Merge relationship test02
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
@ -417,4 +417,19 @@ Feature: Merge feature
|
||||
| ({a: 1}) |
|
||||
| ({a: 2}) |
|
||||
| ({a: 3)) |
|
||||
|
||||
|
||||
Scenario: Merge node with null property error
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
MERGE ({id: null})
|
||||
"""
|
||||
Then an error should be raised
|
||||
|
||||
Scenario: Merge edge with null property error
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
MERGE ()-[:TYPE {id:null}]->()
|
||||
"""
|
||||
Then an error should be raised
|
||||
|
@ -417,3 +417,19 @@ Feature: Merge feature
|
||||
| ({a: 1}) |
|
||||
| ({a: 2}) |
|
||||
| ({a: 3)) |
|
||||
|
||||
Scenario: Merge node with null property error
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
MERGE ({id: null})
|
||||
"""
|
||||
Then an error should be raised
|
||||
|
||||
Scenario: Merge edge with null property error
|
||||
Given an empty graph
|
||||
When executing query:
|
||||
"""
|
||||
MERGE ()-[:TYPE {id:null}]->()
|
||||
"""
|
||||
Then an error should be raised
|
||||
|
Loading…
Reference in New Issue
Block a user