Make graph.Delta zero state invalid for use
Previously, an incorrectly initialised Delta (omission of Action) would result in an Add operation. Make that detectable and return an error.
This commit is contained in:
parent
9088fe376b
commit
46f987ca51
5 changed files with 20 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ package mongo
|
|||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"hash"
|
||||
"sync"
|
||||
|
||||
|
|
@ -218,6 +219,9 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta) error {
|
|||
ids := make(map[string]int)
|
||||
// Pre-check the existence condition.
|
||||
for _, d := range in {
|
||||
if d.Action != graph.Add && d.Action != graph.Delete {
|
||||
return errors.New("mongo: invalid action")
|
||||
}
|
||||
key := qs.getIDForQuad(d.Quad)
|
||||
switch d.Action {
|
||||
case graph.Add:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue