From 0968224a3d2b6eb7c34359ddca5895117b6117ab Mon Sep 17 00:00:00 2001 From: florijan Date: Wed, 3 May 2017 15:55:08 +0200 Subject: [PATCH] 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 --- src/query/plan/operator.cpp | 3 +++ tests/unit/query_plan_create_set_remove_delete.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index aef907d73..73128fa57 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -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: diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index 59781d090..49a414a11 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -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(); + auto delete_op = std::make_shared( + once, std::vector{LITERAL(TypedValue::Null)}, false); + EXPECT_EQ(1, PullAll(delete_op, *dba, symbol_table)); +} + TEST(QueryPlan, DeleteAdvance) { // test queries on empty DB: // CREATE (n)