diff --git a/src/query/db_accessor.hpp b/src/query/db_accessor.hpp index 120f9abac..45994970e 100644 --- a/src/query/db_accessor.hpp +++ b/src/query/db_accessor.hpp @@ -94,6 +94,10 @@ class EdgeAccessor final { VertexAccessor From() const; + VertexAccessor ToWithDeleted() const; + + VertexAccessor FromWithDeleted() const; + bool IsCycle() const; int64_t CypherId() const { return impl_.Gid().AsInt(); } @@ -206,6 +210,10 @@ inline VertexAccessor EdgeAccessor::To() const { return VertexAccessor(impl_.ToV inline VertexAccessor EdgeAccessor::From() const { return VertexAccessor(impl_.FromVertex()); } +inline VertexAccessor EdgeAccessor::ToWithDeleted() const { return VertexAccessor(impl_.ToVertexWithDeleted()); } + +inline VertexAccessor EdgeAccessor::FromWithDeleted() const { return VertexAccessor(impl_.FromVertexWithDeleted()); } + inline bool EdgeAccessor::IsCycle() const { return To() == From(); } class SubgraphVertexAccessor final { diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index dfe8f21cf..bcea66acb 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -487,12 +487,15 @@ mgp_value::mgp_value(const memgraph::query::TypedValue &tv, mgp_graph *graph, me edge_v = std::visit( memgraph::utils::Overloaded{ [&tv, graph, &allocator](memgraph::query::DbAccessor *) { - return allocator.new_object(tv.ValueEdge(), graph); + return allocator.new_object(tv.ValueEdge(), tv.ValueEdge().FromWithDeleted(), + tv.ValueEdge().ToWithDeleted(), graph); }, [&tv, graph, &allocator](memgraph::query::SubgraphDbAccessor *db_impl) { return allocator.new_object( - tv.ValueEdge(), memgraph::query::SubgraphVertexAccessor(tv.ValueEdge().From(), db_impl->getGraph()), - memgraph::query::SubgraphVertexAccessor(tv.ValueEdge().To(), db_impl->getGraph()), graph); + tv.ValueEdge(), + memgraph::query::SubgraphVertexAccessor(tv.ValueEdge().FromWithDeleted(), db_impl->getGraph()), + memgraph::query::SubgraphVertexAccessor(tv.ValueEdge().ToWithDeleted(), db_impl->getGraph()), + graph); }}, graph->impl); break; @@ -847,15 +850,19 @@ mgp_value::mgp_value(mgp_value &&other, memgraph::utils::MemoryResource *m) : ty mgp_value::~mgp_value() noexcept { DeleteValueMember(this); } mgp_edge *mgp_edge::Copy(const mgp_edge &edge, mgp_memory &memory) { - return std::visit( - memgraph::utils::Overloaded{ - [&](memgraph::query::DbAccessor *) { return NewRawMgpObject(&memory, edge.impl, edge.from.graph); }, - [&](memgraph::query::SubgraphDbAccessor *db_impl) { - return NewRawMgpObject( - &memory, edge.impl, memgraph::query::SubgraphVertexAccessor(edge.impl.From(), db_impl->getGraph()), - memgraph::query::SubgraphVertexAccessor(edge.impl.To(), db_impl->getGraph()), edge.to.graph); - }}, - edge.to.graph->impl); + return std::visit(memgraph::utils::Overloaded{ + [&](memgraph::query::DbAccessor *) { + return NewRawMgpObject(&memory, edge.impl, edge.impl.FromWithDeleted(), + edge.impl.ToWithDeleted(), edge.from.graph); + }, + [&](memgraph::query::SubgraphDbAccessor *db_impl) { + return NewRawMgpObject( + &memory, edge.impl, + memgraph::query::SubgraphVertexAccessor(edge.impl.FromWithDeleted(), db_impl->getGraph()), + memgraph::query::SubgraphVertexAccessor(edge.impl.ToWithDeleted(), db_impl->getGraph()), + edge.to.graph); + }}, + edge.to.graph->impl); } mgp_error mgp_value_copy(mgp_value *val, mgp_memory *memory, mgp_value **result) { diff --git a/src/storage/v2/edge_accessor.cpp b/src/storage/v2/edge_accessor.cpp index 3c77f837f..8c7e09c2a 100644 --- a/src/storage/v2/edge_accessor.cpp +++ b/src/storage/v2/edge_accessor.cpp @@ -105,6 +105,15 @@ VertexAccessor EdgeAccessor::ToVertex() const { return VertexAccessor{to_vertex_, transaction_, indices_, constraints_, config_}; } +VertexAccessor EdgeAccessor::FromVertexWithDeleted() const { + return VertexAccessor{from_vertex_, transaction_, indices_, + constraints_, config_, for_deleted_ && from_vertex_->deleted}; +} + +VertexAccessor EdgeAccessor::ToVertexWithDeleted() const { + return VertexAccessor{to_vertex_, transaction_, indices_, constraints_, config_, for_deleted_ && to_vertex_->deleted}; +} + Result EdgeAccessor::SetProperty(PropertyId property, const PropertyValue &value) { utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; if (!config_.properties_on_edges) return Error::PROPERTIES_DISABLED; diff --git a/src/storage/v2/edge_accessor.hpp b/src/storage/v2/edge_accessor.hpp index 2b87b9838..5ae5fe4dc 100644 --- a/src/storage/v2/edge_accessor.hpp +++ b/src/storage/v2/edge_accessor.hpp @@ -52,6 +52,10 @@ class EdgeAccessor final { VertexAccessor ToVertex() const; + VertexAccessor FromVertexWithDeleted() const; + + VertexAccessor ToVertexWithDeleted() const; + EdgeTypeId EdgeType() const { return edge_type_; } /// Set a property value and return the old value.