bolt
bolt copied to clipboard
Deleting bucket after inserting a nil value
After executing the following steps in a single transaction:
- Create a bucket
- Add key with a
nilvalue to the bucket - Delete the bucket
I get the following error:
delete bucket: incompatible value
If value in point (2) is not nil, or deleting from a different transaction, everything works as expected.
Code replicating the problem:
package main
import (
"fmt"
"github.com/boltdb/bolt"
)
func main() {
db, _ := bolt.Open("/tmp/bolt.db", 0666, nil)
defer db.Close()
tx, _ := db.Begin(true)
defer tx.Rollback()
bucketName := []byte("oops")
b, _ := tx.CreateBucket(bucketName)
b.Put([]byte("key"), nil) // putting []byte{} works fine
fmt.Println(tx.DeleteBucket(bucketName))
}
// Output:
// delete bucket: incompatible value
This is still reproducible