From b3e18e83b4622904d7e8de96f6466333011e1aec Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Fri, 26 May 2017 21:35:23 +0300 Subject: [PATCH] accept quad.Value instead of graph.Value for RemoveNode; fix #607 --- graph/quadwriter.go | 2 +- writer/single.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/graph/quadwriter.go b/graph/quadwriter.go index 90a339ab0..c201970a7 100644 --- a/graph/quadwriter.go +++ b/graph/quadwriter.go @@ -142,7 +142,7 @@ type QuadWriter interface { ApplyTransaction(*Transaction) error // RemoveNode removes all quads which have the given node as subject, predicate, object, or label. - RemoveNode(Value) error + RemoveNode(quad.Value) error // Close cleans up replication and closes the writing aspect of the database. Close() error diff --git a/writer/single.go b/writer/single.go index 2222140c1..e6c3f65fe 100644 --- a/writer/single.go +++ b/writer/single.go @@ -103,11 +103,15 @@ func (s *Single) RemoveQuad(q quad.Quad) error { } // RemoveNode removes all quads with the given value -func (s *Single) RemoveNode(v graph.Value) error { +func (s *Single) RemoveNode(v quad.Value) error { + gv := s.qs.ValueOf(v) + if gv == nil { + return nil + } var deltas []graph.Delta // TODO(dennwc): QuadStore may remove node without iterations. Consider optional interface for this. for _, d := range []quad.Direction{quad.Subject, quad.Predicate, quad.Object, quad.Label} { - it := s.qs.QuadIterator(d, v) + it := s.qs.QuadIterator(d, gv) for it.Next() { deltas = append(deltas, graph.Delta{ ID: s.currentID.Next(),