Skip to content
New issue

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

upgrade badger to v4 #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"sort"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

// AggregateResult allows you to access the results of an aggregate query
Expand Down
2 changes: 1 addition & 1 deletion bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"
"testing"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/timshannon/badgerhold/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package badgerhold

import (
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

// Delete deletes a record from the badgerhold, datatype just needs to be an example of the type stored so that
Expand Down
2 changes: 1 addition & 1 deletion delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/timshannon/badgerhold/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"
"time"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/timshannon/badgerhold/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"reflect"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

// ErrNotFound is returned when no data is found for the given key
Expand Down
2 changes: 1 addition & 1 deletion get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/timshannon/badgerhold/v4"
)

Expand Down
22 changes: 19 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
module github.com/timshannon/badgerhold/v4

require github.com/dgraph-io/badger/v4 v4.0.1

require (
github.com/dgraph-io/badger/v3 v3.2103.1
github.com/timshannon/badgerhold/v3 v3.0.0-20210909134927-2b6764d68c1e
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v2.0.0+incompatible // indirect
github.com/klauspost/compress v1.13.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)

go 1.13
go 1.19
64 changes: 8 additions & 56 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"sort"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

const indexPrefix = "_bhIndex"
Expand Down
2 changes: 1 addition & 1 deletion put.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"reflect"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

// ErrKeyExists is the error returned when data is being Inserted for a Key that already exists
Expand Down
2 changes: 1 addition & 1 deletion put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
"github.com/timshannon/badgerhold/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"unicode"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"sync"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

const (
Expand Down
18 changes: 8 additions & 10 deletions store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/timshannon/badgerhold/v4"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"runtime"
"testing"

v3 "github.com/timshannon/badgerhold/v3"
"github.com/timshannon/badgerhold/v4"
)

func TestOpen(t *testing.T) {
Expand Down Expand Up @@ -135,7 +133,7 @@ func TestIssue115(t *testing.T) {
}

func TestIssue70TypePrefixCollisionWithV3(t *testing.T) {
testWrapV3(t, func(store *v3.Store, t *testing.T) {
testWrapV3(t, func(store *badgerhold.Store, t *testing.T) {

type TestStruct struct {
Value int
Expand All @@ -150,7 +148,7 @@ func TestIssue70TypePrefixCollisionWithV3(t *testing.T) {
ok(t, store.Insert(i, TestStructCollision{Value: i}))
}

query := v3.Where(v3.Key).In(0, 1, 2, 3, 4)
query := badgerhold.Where(badgerhold.Key).In(0, 1, 2, 3, 4)
var results []TestStruct
err := store.Find(
&results,
Expand Down Expand Up @@ -226,13 +224,13 @@ func testWrapWithOpt(t *testing.T, opt badgerhold.Options, tests func(store *bad
os.RemoveAll(opt.Dir)
}

func testWrapV3(t *testing.T, tests func(store *v3.Store, t *testing.T)) {
func testWrapV3(t *testing.T, tests func(store *badgerhold.Store, t *testing.T)) {
testWrapV3WithOpt(t, testV3Options(), tests)
}

func testWrapV3WithOpt(t *testing.T, opt v3.Options, tests func(store *v3.Store, t *testing.T)) {
func testWrapV3WithOpt(t *testing.T, opt badgerhold.Options, tests func(store *badgerhold.Store, t *testing.T)) {
var err error
store, err := v3.Open(opt)
store, err := badgerhold.Open(opt)
if err != nil {
t.Fatalf("Error opening %s: %s", opt.Dir, err)
}
Expand Down Expand Up @@ -267,8 +265,8 @@ func testOptions() badgerhold.Options {
return opt
}

func testV3Options() v3.Options {
opt := v3.DefaultOptions
func testV3Options() badgerhold.Options {
opt := badgerhold.DefaultOptions
opt.Dir = tempdir()
opt.ValueDir = opt.Dir
opt.Logger = emptyLogger{}
Expand Down