diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index 040edf5fe..f83cebda2 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -354,6 +354,9 @@ EdgeInfoForDeletion Storage::Accessor::PrepareDeletableEdges(const std::unordere // also add edges which we want to delete from the query for (const auto &edge_accessor : edges) { + if (edge_accessor->from_vertex_->deleted || edge_accessor->to_vertex_->deleted) { + continue; + } partial_src_vertices.insert(edge_accessor->from_vertex_); partial_dest_vertices.insert(edge_accessor->to_vertex_); diff --git a/tests/gql_behave/tests/memgraph_V1/features/delete.feature b/tests/gql_behave/tests/memgraph_V1/features/delete.feature index 027e40b94..a9f59aca4 100644 --- a/tests/gql_behave/tests/memgraph_V1/features/delete.feature +++ b/tests/gql_behave/tests/memgraph_V1/features/delete.feature @@ -209,3 +209,13 @@ Feature: Delete MATCH (n) DETACH DELETE n SET n.prop = 1 WITH n RETURN n """ Then an error should be raised + + Scenario: Delete a relationship that is already deleted in a previous DETACH DELETE clause + Given an empty graph + When executing query: + """ + CREATE (n0)<-[r0:T]-(n1) DETACH DELETE n0 DETACH DELETE r0 RETURN n1; + """ + Then the result should be: + | n1 | + | () |