Query::Delete - can now delete Null (naturally occuring in optional match)

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D339
This commit is contained in:
florijan 2017-05-03 15:55:08 +02:00
parent cb7310fb6a
commit 0968224a3d
2 changed files with 16 additions and 0 deletions

View File

@ -576,7 +576,10 @@ bool Delete::DeleteCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
"connections. Consider using DETACH DELETE.");
break;
}
// skip Edges (already deleted) and Nulls (can occur in optional match)
case TypedValue::Type::Edge:
case TypedValue::Type::Null:
break;
// check we're not trying to delete anything except vertices and edges
default:

View File

@ -412,6 +412,19 @@ TEST(QueryPlan, DeleteReturn) {
EXPECT_EQ(0, CountIterable(dba->vertices()));
}
TEST(QueryPlan, DeleteNull) {
// test (simplified) WITH Null as x delete x
Dbms dbms;
auto dba = dbms.active();
AstTreeStorage storage;
SymbolTable symbol_table;
auto once = std::make_shared<Once>();
auto delete_op = std::make_shared<plan::Delete>(
once, std::vector<Expression *>{LITERAL(TypedValue::Null)}, false);
EXPECT_EQ(1, PullAll(delete_op, *dba, symbol_table));
}
TEST(QueryPlan, DeleteAdvance) {
// test queries on empty DB:
// CREATE (n)