Skip to content

Commit

Permalink
kv: return quad not exists errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Dec 19, 2017
1 parent 0a1bd9d commit 73089a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion graph/graphtest/graphtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ func TestAddRemove(t testing.TB, gen testutil.DatabaseFunc, conf *Config) {
err = w.RemoveQuad(toRemove)
require.Nil(t, err, "RemoveQuad failed")
err = w.RemoveQuad(toRemove)
require.True(t, graph.IsQuadNotExist(err), "expected not exists error")
require.True(t, graph.IsQuadNotExist(err), "expected not exists error, got: %v", err)

if !conf.SkipNodeDelAfterQuadDel {
expect = []string{
Expand Down
7 changes: 5 additions & 2 deletions graph/kv/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ nextDelta:
if ignoreOpts.IgnoreMissing {
continue nextDelta
}
return fmt.Errorf("Deleting unknown quad: %s", d.Quad)
return &graph.DeltaError{Delta: d, Err: graph.ErrQuadNotExist}
}
node, err := qs.createNodePrimitive(val)
if err != nil {
Expand All @@ -214,7 +214,10 @@ nextDelta:
p, err := qs.hasPrimitive(tx, &link, true)
if err != nil {
return err
} else if p == nil {
} else if p == nil || p.Deleted {
if !ignoreOpts.IgnoreMissing {
return &graph.DeltaError{Delta: d, Err: graph.ErrQuadNotExist}
}
continue
}
err = qs.markAsDead(tx, p)
Expand Down

0 comments on commit 73089a9

Please sign in to comment.