updated mongo driver dependencies to v2
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m27s

This commit is contained in:
2026-04-21 12:11:38 +02:00
parent 84b87d61f2
commit 0c37dd5576
36 changed files with 187 additions and 582 deletions
+2 -3
View File
@@ -5,13 +5,12 @@ import (
ct "git.blackforestbytes.com/BlackForestBytes/goext/cursortoken"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/mongo"
"reflect"
)
type EntityID interface {
MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue() (byte, []byte, error)
String() string
}
+1 -1
View File
@@ -2,8 +2,8 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"go.mongodb.org/mongo-driver/v2/bson"
)
func (c *Coll[TData]) decodeSingle(ctx context.Context, dec Decodable) (TData, error) {
+1 -1
View File
@@ -1,6 +1,6 @@
package wmo
import "go.mongodb.org/mongo-driver/mongo"
import "go.mongodb.org/mongo-driver/v2/mongo"
func W[TData any](collection *mongo.Collection) *Coll[TData] {
c := Coll[TData]{coll: collection}
+5 -5
View File
@@ -2,13 +2,13 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func (c *Coll[TData]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, opts ...*options.AggregateOptions) ([]TData, error) {
func (c *Coll[TData]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, opts ...options.Lister[options.AggregateOptions]) ([]TData, error) {
for _, ppl := range c.extraModPipeline {
pipeline = langext.ArrConcat(pipeline, ppl(ctx))
@@ -29,7 +29,7 @@ func (c *Coll[TData]) Aggregate(ctx context.Context, pipeline mongo.Pipeline, op
return res, nil
}
func (c *Coll[TData]) AggregateOneOpt(ctx context.Context, pipeline mongo.Pipeline, opts ...*options.AggregateOptions) (*TData, error) {
func (c *Coll[TData]) AggregateOneOpt(ctx context.Context, pipeline mongo.Pipeline, opts ...options.Lister[options.AggregateOptions]) (*TData, error) {
for _, ppl := range c.extraModPipeline {
pipeline = langext.ArrConcat(pipeline, ppl(ctx))
@@ -53,7 +53,7 @@ func (c *Coll[TData]) AggregateOneOpt(ctx context.Context, pipeline mongo.Pipeli
return nil, nil
}
func (c *Coll[TData]) AggregateOne(ctx context.Context, pipeline mongo.Pipeline, opts ...*options.AggregateOptions) (TData, error) {
func (c *Coll[TData]) AggregateOne(ctx context.Context, pipeline mongo.Pipeline, opts ...options.Lister[options.AggregateOptions]) (TData, error) {
for _, ppl := range c.extraModPipeline {
pipeline = langext.ArrConcat(pipeline, ppl(ctx))
+2 -2
View File
@@ -2,9 +2,9 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
func (c *Coll[TData]) DeleteOneByID(ctx context.Context, id EntityID) error {
+9 -22
View File
@@ -2,11 +2,11 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"iter"
)
@@ -51,13 +51,15 @@ func (c *Coll[TData]) createFindQuery(ctx context.Context, filter bson.M, opts .
}
}
convOpts := make([]*options.AggregateOptions, 0, len(opts))
convOpts := make([]options.Lister[options.AggregateOptions], 0, len(opts))
for _, v := range opts {
vConv, err := convertFindOpt(v)
if err != nil {
return nil, exerr.Wrap(err, "mongo-aggregation failed").Any("pipeline", pipeline).Str("collection", c.Name()).Build()
}
convOpts = append(convOpts, vConv)
if vConv != nil {
convOpts = append(convOpts, vConv)
}
}
cursor, err := c.coll.Aggregate(ctx, pipeline, convOpts...)
@@ -137,7 +139,7 @@ func (c *Coll[TData]) FindIterate(ctx context.Context, filter bson.M, opts ...*o
}
// converts FindOptions to AggregateOptions
func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
func convertFindOpt(v *options.FindOptions) (*options.AggregateOptionsBuilder, error) {
if v == nil {
return nil, nil
}
@@ -157,7 +159,7 @@ func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
r.SetCollation(v.Collation)
}
if v.Comment != nil {
r.SetComment(*v.Comment)
r.SetComment(v.Comment)
}
if v.CursorType != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'CursorType' (cannot convert to AggregateOptions)").Build()
@@ -165,33 +167,18 @@ func convertFindOpt(v *options.FindOptions) (*options.AggregateOptions, error) {
if v.Hint != nil {
r.SetHint(v.Hint)
}
if v.Max != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Max' (cannot convert to AggregateOptions)").Build()
}
if v.MaxAwaitTime != nil {
r.SetMaxAwaitTime(*v.MaxAwaitTime)
}
if v.MaxTime != nil {
r.SetMaxTime(*v.MaxTime)
}
if v.Min != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Min' (cannot convert to AggregateOptions)").Build()
}
if v.NoCursorTimeout != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'NoCursorTimeout' (cannot convert to AggregateOptions)").Build()
}
if v.OplogReplay != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'OplogReplay' (cannot convert to AggregateOptions)").Build()
}
if v.ReturnKey != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'ReturnKey' (cannot convert to AggregateOptions)").Build()
}
if v.ShowRecordID != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'ShowRecordID' (cannot convert to AggregateOptions)").Build()
}
if v.Snapshot != nil {
return nil, exerr.New(exerr.TypeMongoInvalidOpt, "Invalid option 'Snapshot' (cannot convert to AggregateOptions)").Build()
}
if v.Let != nil {
r.SetLet(v.Let)
}
+2 -2
View File
@@ -3,10 +3,10 @@ package wmo
import (
"context"
"errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
func (c *Coll[TData]) FindOne(ctx context.Context, filter bson.M) (TData, error) {
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
func (c *Coll[TData]) InsertOne(ctx context.Context, valueIn TData) (TData, error) {
+2 -2
View File
@@ -2,11 +2,11 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
ct "git.blackforestbytes.com/BlackForestBytes/goext/cursortoken"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"iter"
)
+2 -2
View File
@@ -2,11 +2,11 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
pag "git.blackforestbytes.com/BlackForestBytes/goext/pagination"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"iter"
)
+3 -3
View File
@@ -2,10 +2,10 @@ package wmo
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"git.blackforestbytes.com/BlackForestBytes/goext/exerr"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func (c *Coll[TData]) FindOneAndUpdate(ctx context.Context, filterQuery bson.M, updateQuery bson.M) (TData, error) {
+4 -4
View File
@@ -9,8 +9,8 @@ import (
"git.blackforestbytes.com/BlackForestBytes/goext/rfctime"
"git.blackforestbytes.com/BlackForestBytes/goext/timeext"
"git.blackforestbytes.com/BlackForestBytes/goext/tst"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
func TestReflectionGetFieldType(t *testing.T) {
@@ -234,8 +234,8 @@ func TestReflectionGetFieldValueAsTokenString(t *testing.T) {
func TestReflectionWithInterface(t *testing.T) {
type TestData struct {
ID primitive.ObjectID `bson:"_id"`
CDate time.Time `bson:"cdate"`
ID bson.ObjectID `bson:"_id"`
CDate time.Time `bson:"cdate"`
}
type TestInterface any