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
+13 -44
View File
@@ -4,11 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"strconv"
"strings"
"time"
@@ -83,8 +79,8 @@ func (t *Date) UnmarshalText(data []byte) error {
return t.ParseString(string(data))
}
func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bsontype.Null {
func (t *Date) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -92,12 +88,12 @@ func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
*t = Date{}
return nil
}
if bt != bsontype.String {
return errors.New(fmt.Sprintf("cannot unmarshal %v into Date", bt))
if bson.Type(bt) != bson.TypeString {
return errors.New(fmt.Sprintf("cannot unmarshal %v into Date", bson.Type(bt)))
}
var tt string
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -120,43 +116,16 @@ func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
return nil
}
func (t Date) MarshalBSONValue() (bsontype.Type, []byte, error) {
func (t Date) MarshalBSONValue() (byte, []byte, error) {
var tp bson.Type
var data []byte
var err error
if t.IsZero() {
return bson.MarshalValue("")
}
return bson.MarshalValue(t.String())
}
func (t Date) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
tp, data, err = bson.MarshalValue("")
} else {
val.Set(reflect.ValueOf(t))
tp, data, err = bson.MarshalValue(t.String())
}
return nil
return byte(tp), data, err
}
func (t Date) Serialize() string {
+9 -44
View File
@@ -4,13 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
"reflect"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/v2/bson"
)
type RFC3339Time time.Time
@@ -69,8 +65,8 @@ func (t *RFC3339Time) UnmarshalText(data []byte) error {
return nil
}
func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (t *RFC3339Time) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -78,11 +74,11 @@ func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
*t = RFC3339Time{}
return nil
}
if bt != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bt))
if bson.Type(bt) != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bson.Type(bt)))
}
var tt time.Time
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -90,40 +86,9 @@ func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
return nil
}
func (t RFC3339Time) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(time.Time(t))
}
func (t RFC3339Time) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
} else {
val.Set(reflect.ValueOf(t))
}
return nil
func (t RFC3339Time) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(time.Time(t))
return byte(tp), data, err
}
func (t RFC3339Time) Serialize() string {
+9 -44
View File
@@ -4,11 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"time"
)
@@ -68,8 +64,8 @@ func (t *RFC3339NanoTime) UnmarshalText(data []byte) error {
return nil
}
func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (t *RFC3339NanoTime) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -77,11 +73,11 @@ func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) erro
*t = RFC3339NanoTime{}
return nil
}
if bt != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339NanoTime", bt))
if bson.Type(bt) != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339NanoTime", bson.Type(bt)))
}
var tt time.Time
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -89,40 +85,9 @@ func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) erro
return nil
}
func (t RFC3339NanoTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(time.Time(t))
}
func (t RFC3339NanoTime) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
} else {
val.Set(reflect.ValueOf(t))
}
return nil
func (t RFC3339NanoTime) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(time.Time(t))
return byte(tp), data, err
}
func (t RFC3339NanoTime) Serialize() string {
+9 -44
View File
@@ -5,11 +5,7 @@ import (
"errors"
"fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/timeext"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"time"
)
@@ -61,8 +57,8 @@ func (d SecondsF64) MarshalJSON() ([]byte, error) {
return json.Marshal(secs)
}
func (d *SecondsF64) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (d *SecondsF64) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -70,11 +66,11 @@ func (d *SecondsF64) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
*d = SecondsF64(0)
return nil
}
if bt != bson.TypeDouble {
return errors.New(fmt.Sprintf("cannot unmarshal %v into SecondsF64", bt))
if bson.Type(bt) != bson.TypeDouble {
return errors.New(fmt.Sprintf("cannot unmarshal %v into SecondsF64", bson.Type(bt)))
}
var secValue float64
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&secValue)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&secValue)
if err != nil {
return err
}
@@ -82,40 +78,9 @@ func (d *SecondsF64) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
return nil
}
func (d SecondsF64) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(d.Seconds())
}
func (d SecondsF64) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = d.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&d))
} else {
val.Set(reflect.ValueOf(d))
}
return nil
func (d SecondsF64) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(d.Seconds())
return byte(tp), data, err
}
func NewSecondsF64(t time.Duration) SecondsF64 {
+9 -44
View File
@@ -4,11 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"strconv"
"time"
)
@@ -66,8 +62,8 @@ func (t *UnixTime) UnmarshalText(data []byte) error {
return nil
}
func (t *UnixTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (t *UnixTime) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -75,11 +71,11 @@ func (t *UnixTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
*t = UnixTime{}
return nil
}
if bt != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixTime", bt))
if bson.Type(bt) != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixTime", bson.Type(bt)))
}
var tt time.Time
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -87,40 +83,9 @@ func (t *UnixTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
return nil
}
func (t UnixTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(time.Time(t))
}
func (t UnixTime) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
} else {
val.Set(reflect.ValueOf(t))
}
return nil
func (t UnixTime) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(time.Time(t))
return byte(tp), data, err
}
func (t UnixTime) Serialize() string {
+9 -44
View File
@@ -4,11 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"strconv"
"time"
)
@@ -66,8 +62,8 @@ func (t *UnixMilliTime) UnmarshalText(data []byte) error {
return nil
}
func (t *UnixMilliTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (t *UnixMilliTime) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -75,11 +71,11 @@ func (t *UnixMilliTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error
*t = UnixMilliTime{}
return nil
}
if bt != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixMilliTime", bt))
if bson.Type(bt) != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixMilliTime", bson.Type(bt)))
}
var tt time.Time
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -87,40 +83,9 @@ func (t *UnixMilliTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error
return nil
}
func (t UnixMilliTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(time.Time(t))
}
func (t UnixMilliTime) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
} else {
val.Set(reflect.ValueOf(t))
}
return nil
func (t UnixMilliTime) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(time.Time(t))
return byte(tp), data, err
}
func (t UnixMilliTime) Serialize() string {
+9 -44
View File
@@ -4,11 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"go.mongodb.org/mongo-driver/v2/bson"
"strconv"
"time"
)
@@ -66,8 +62,8 @@ func (t *UnixNanoTime) UnmarshalText(data []byte) error {
return nil
}
func (t *UnixNanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
if bt == bson.TypeNull {
func (t *UnixNanoTime) UnmarshalBSONValue(bt byte, data []byte) error {
if bson.Type(bt) == bson.TypeNull {
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
// https://stackoverflow.com/questions/75167597
@@ -75,11 +71,11 @@ func (t *UnixNanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
*t = UnixNanoTime{}
return nil
}
if bt != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixNanoTime", bt))
if bson.Type(bt) != bson.TypeDateTime {
return errors.New(fmt.Sprintf("cannot unmarshal %v into UnixNanoTime", bson.Type(bt)))
}
var tt time.Time
err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt)
err := bson.RawValue{Type: bson.Type(bt), Value: data}.Unmarshal(&tt)
if err != nil {
return err
}
@@ -87,40 +83,9 @@ func (t *UnixNanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
return nil
}
func (t UnixNanoTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
return bson.MarshalValue(time.Time(t))
}
func (t UnixNanoTime) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if val.Kind() == reflect.Pointer && val.IsNil() {
if !val.CanSet() {
return errors.New("ValueUnmarshalerDecodeValue")
}
val.Set(reflect.New(val.Type().Elem()))
}
tp, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer && len(src) == 0 {
val.Set(reflect.Zero(val.Type()))
return nil
}
err = t.UnmarshalBSONValue(tp, src)
if err != nil {
return err
}
if val.Kind() == reflect.Pointer {
val.Set(reflect.ValueOf(&t))
} else {
val.Set(reflect.ValueOf(t))
}
return nil
func (t UnixNanoTime) MarshalBSONValue() (byte, []byte, error) {
tp, data, err := bson.MarshalValue(time.Time(t))
return byte(tp), data, err
}
func (t UnixNanoTime) Serialize() string {