We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nil
a09e983
1.22.4
Yes
Linux workstation 6.8.11-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 27 14:53:33 UTC 2024 x86_64 GNU/Linux
Test:
func TestSetAndGetEmptySlice(t *testing.T) { dir := t.TempDir() db, err := Open(DefaultOptions(dir)) require.NoError(t, err) defer func() { require.NoError(t, db.Close()) }() key := []byte("key") value := []byte{} err = db.Update(func(txn *Txn) error { return txn.Set(key, value) }) require.NoError(t, err) var item *Item err = db.View(func(txn *Txn) (dbErr error) { item, dbErr = txn.Get(key) return dbErr }) require.NoError(t, err) require.NotNil(t, item) dbValue, err := item.ValueCopy(nil) require.NoError(t, err) require.Equal(t, value, dbValue) }
Test result:
--- FAIL: TestSetAndGetEmptySlice (0.01s) ... Error: Not equal: expected: []byte{} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,3 +1,2 @@ -([]uint8) { -} +([]uint8) <nil> Test: TestSetAndGetEmptySlice FAIL FAIL github.com/dgraph-io/badger/v4 0.021s FAIL
An empty slice should be returned.
The similar test for bbolt passes:
func TestDB_SetAndGetEmptySlice(t *testing.T) { db := btesting.MustCreateDB(t) bucket := []byte("test bucket") key := []byte("key") value := []byte{} err := db.Update(func(tx *bolt.Tx) error { b, err := tx.CreateBucketIfNotExists(bucket) if err != nil { return err } return b.Put(key, value) }) require.NoError(t, err) var dbValue []byte err = db.View(func(tx *bolt.Tx) error { b := tx.Bucket(bucket) dbValue = b.Get(key) return nil }) require.NoError(t, err) require.Equal(t, value, dbValue) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What version of Badger are you using?
a09e983
What version of Go are you using?
1.22.4
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
Linux workstation 6.8.11-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 27 14:53:33 UTC 2024 x86_64 GNU/Linux
What steps will reproduce the bug?
Test:
Test result:
Expected behavior and actual result.
An empty slice should be returned.
Additional information
The similar test for bbolt passes:
The text was updated successfully, but these errors were encountered: