Browse Source

loopdb: allow restored databases to contain nil values

pull/238/head
Joost Jager 7 months ago
parent
commit
eaf8239e49
No known key found for this signature in database GPG Key ID: A61B9D4C393C59C7
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      loopdb/raw_db_test.go

+ 10
- 2
loopdb/raw_db_test.go View File

@ -2,7 +2,6 @@ package loopdb
import (
"encoding/hex"
"errors"
"fmt"
"strings"
@ -88,6 +87,15 @@ func restoreDB(bucket *bbolt.Bucket, data map[string]interface{}) error {
for k, v := range data {
key := []byte(k)
// Store nil values.
if v == nil {
err := bucket.Put(key, nil)
if err != nil {
return err
}
continue
}
switch value := v.(type) {
// Key contains value.
@ -109,7 +117,7 @@ func restoreDB(bucket *bbolt.Bucket, data map[string]interface{}) error {
}
default:
return errors.New("invalid type")
return fmt.Errorf("invalid type %T", value)
}
}

Loading…
Cancel
Save