Skip to content

Commit aaed5f3

Browse files
author
Gao, Jian (Allen)
committed
build(deps): update mongo-driver to v2
Signed-off-by: Allen Gao <[email protected]>
1 parent 536ea3f commit aaed5f3

File tree

11 files changed

+47
-43
lines changed

11 files changed

+47
-43
lines changed

bson.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"database/sql/driver"
88
"fmt"
99

10-
bsonprim "go.mongodb.org/mongo-driver/bson/primitive"
10+
bsonprim "go.mongodb.org/mongo-driver/v2/bson"
1111
)
1212

1313
func init() {
@@ -22,7 +22,7 @@ func IsBSONObjectID(str string) bool {
2222
return err == nil
2323
}
2424

25-
// ObjectId represents a BSON object ID (alias to go.mongodb.org/mongo-driver/bson/primitive.ObjectID)
25+
// ObjectId represents a BSON object ID (alias to go.mongodb.org/mongo-driver/v2/bson.ObjectID)
2626
//
2727
// swagger:strfmt bsonobjectid
2828
type ObjectId bsonprim.ObjectID //nolint:revive

bson_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/go-openapi/testify/v2/assert"
1010
"github.com/go-openapi/testify/v2/require"
11-
"go.mongodb.org/mongo-driver/bson"
11+
"go.mongodb.org/mongo-driver/v2/bson"
1212
)
1313

1414
func TestBSONObjectId_fullCycle(t *testing.T) {
@@ -45,7 +45,6 @@ func TestBSONObjectId_fullCycle(t *testing.T) {
4545
err = bson.Unmarshal(bsonBytes, &idCopy)
4646
require.NoError(t, err)
4747
assert.Equal(t, id, idCopy)
48-
4948
}
5049

5150
func TestDeepCopyObjectId(t *testing.T) {

date_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515
"github.com/go-openapi/testify/v2/require"
1616
)
1717

18-
var _ sql.Scanner = &Date{}
19-
var _ driver.Valuer = Date{}
18+
var (
19+
_ sql.Scanner = &Date{}
20+
_ driver.Valuer = Date{}
21+
)
2022

2123
func TestDate(t *testing.T) {
2224
pp := Date{}

default_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ func invalidUUID4s() []string {
301301
strings.Replace(other5.String(), "-", "", 2),
302302
}
303303
}
304+
304305
func TestFormatUUID4(t *testing.T) {
305306
first4 := uuid.Must(uuid.NewRandom())
306307
other4 := uuid.Must(uuid.NewRandom())
@@ -436,6 +437,7 @@ func invalidUUIDs() []string {
436437
strings.Replace(other5.String(), "-", "", 2),
437438
}
438439
}
440+
439441
func TestFormatUUID(t *testing.T) {
440442
first5 := uuid.NewSHA1(uuid.NameSpaceURL, []byte("somewhere.com"))
441443
other5 := uuid.NewSHA1(uuid.NameSpaceURL, []byte("somewhereelse.com"))
@@ -1104,7 +1106,6 @@ func BenchmarkIsHostname(b *testing.B) {
11041106
}
11051107
}
11061108
return valid
1107-
11081109
}))
11091110
b.Run("IsHostname - idna", benchmarkIs(hostnames, IsHostname))
11101111
}

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/go-openapi/strfmt
22

3+
go 1.25.0
4+
35
require (
4-
github.com/go-openapi/errors v0.22.6
6+
github.com/go-openapi/errors v0.22.7
57
github.com/go-openapi/testify/v2 v2.4.0
68
github.com/go-viper/mapstructure/v2 v2.5.0
79
github.com/google/uuid v1.6.0
810
github.com/oklog/ulid/v2 v2.1.1
9-
go.mongodb.org/mongo-driver v1.17.9
11+
go.mongodb.org/mongo-driver/v2 v2.5.0
1012
golang.org/x/net v0.51.0
1113
)
1214

1315
require golang.org/x/text v0.34.0 // indirect
14-
15-
go 1.25.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/go-openapi/errors v0.22.6 h1:eDxcf89O8odEnohIXwEjY1IB4ph5vmbUsBMsFNwXWPo=
4-
github.com/go-openapi/errors v0.22.6/go.mod h1:z9S8ASTUqx7+CP1Q8dD8ewGH/1JWFFLX/2PmAYNQLgk=
3+
github.com/go-openapi/errors v0.22.7 h1:JLFBGC0Apwdzw3484MmBqspjPbwa2SHvpDm0u5aGhUA=
4+
github.com/go-openapi/errors v0.22.7/go.mod h1://QW6SD9OsWtH6gHllUCddOXDL0tk0ZGNYHwsw4sW3w=
55
github.com/go-openapi/testify/v2 v2.4.0 h1:8nsPrHVCWkQ4p8h1EsRVymA2XABB4OT40gcvAu+voFM=
66
github.com/go-openapi/testify/v2 v2.4.0/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
77
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
@@ -13,8 +13,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
1313
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
1414
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
1515
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
16-
go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU=
17-
go.mongodb.org/mongo-driver v1.17.9/go.mod h1:LlOhpH5NUEfhxcAwG0UEkMqwYcc4JU18gtCdGudk/tQ=
16+
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
17+
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
1818
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
1919
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
2020
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=

mongo.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/oklog/ulid/v2"
13-
"go.mongodb.org/mongo-driver/bson"
14-
"go.mongodb.org/mongo-driver/bson/bsontype"
15-
bsonprim "go.mongodb.org/mongo-driver/bson/primitive"
13+
"go.mongodb.org/mongo-driver/v2/bson"
1614
)
1715

1816
var (
@@ -174,7 +172,7 @@ func (t *DateTime) UnmarshalBSON(data []byte) error {
174172
//
175173
// Marshals a DateTime as a bson.TypeDateTime, an int64 representing
176174
// milliseconds since epoch.
177-
func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
175+
func (t DateTime) MarshalBSONValue() (byte, []byte, error) {
178176
// UnixNano cannot be used directly, the result of calling UnixNano on the zero
179177
// Time is undefined. Thats why we use time.Nanosecond() instead.
180178

@@ -183,15 +181,15 @@ func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
183181
buf := make([]byte, bsonDateTimeSize)
184182
binary.LittleEndian.PutUint64(buf, uint64(i64)) //nolint:gosec // it's okay to handle negative int64 this way
185183

186-
return bson.TypeDateTime, buf, nil
184+
return byte(bson.TypeDateTime), buf, nil
187185
}
188186

189187
// UnmarshalBSONValue is an interface implemented by types that can unmarshal a
190188
// BSON value representation of themselves. The BSON bytes and type can be
191189
// assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it
192190
// wishes to retain the data after returning.
193-
func (t *DateTime) UnmarshalBSONValue(tpe bsontype.Type, data []byte) error {
194-
if tpe == bson.TypeNull {
191+
func (t *DateTime) UnmarshalBSONValue(tpe byte, data []byte) error {
192+
if tpe == byte(bson.TypeNull) {
195193
*t = DateTime{}
196194
return nil
197195
}
@@ -611,13 +609,13 @@ func (r *RGBColor) UnmarshalBSON(data []byte) error {
611609

612610
// MarshalBSON renders the object id as a BSON document
613611
func (id ObjectId) MarshalBSON() ([]byte, error) {
614-
return bson.Marshal(bson.M{"data": bsonprim.ObjectID(id)})
612+
return bson.Marshal(bson.M{"data": bson.ObjectID(id)})
615613
}
616614

617615
// UnmarshalBSON reads the objectId from a BSON document
618616
func (id *ObjectId) UnmarshalBSON(data []byte) error {
619617
var obj struct {
620-
Data bsonprim.ObjectID
618+
Data bson.ObjectID
621619
}
622620
if err := bson.Unmarshal(data, &obj); err != nil {
623621
return err
@@ -629,17 +627,17 @@ func (id *ObjectId) UnmarshalBSON(data []byte) error {
629627
// MarshalBSONValue is an interface implemented by types that can marshal themselves
630628
// into a BSON document represented as bytes. The bytes returned must be a valid
631629
// BSON document if the error is nil.
632-
func (id ObjectId) MarshalBSONValue() (bsontype.Type, []byte, error) {
633-
oid := bsonprim.ObjectID(id)
634-
return bson.TypeObjectID, oid[:], nil
630+
func (id ObjectId) MarshalBSONValue() (byte, []byte, error) {
631+
oid := bson.ObjectID(id)
632+
return byte(bson.TypeObjectID), oid[:], nil
635633
}
636634

637635
// UnmarshalBSONValue is an interface implemented by types that can unmarshal a
638636
// BSON value representation of themselves. The BSON bytes and type can be
639637
// assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it
640638
// wishes to retain the data after returning.
641-
func (id *ObjectId) UnmarshalBSONValue(_ bsontype.Type, data []byte) error {
642-
var oid bsonprim.ObjectID
639+
func (id *ObjectId) UnmarshalBSONValue(_ byte, data []byte) error {
640+
var oid bson.ObjectID
643641
copy(oid[:], data)
644642
*id = ObjectId(oid)
645643
return nil

mongo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/go-openapi/testify/v2/assert"
1212
"github.com/go-openapi/testify/v2/require"
1313
"github.com/google/uuid"
14-
"go.mongodb.org/mongo-driver/bson"
14+
"go.mongodb.org/mongo-driver/v2/bson"
1515
)
1616

1717
type testableBSONFormat interface {

time.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import (
1212
"time"
1313
)
1414

15-
var (
16-
// UnixZero sets the zero unix UTC timestamp we want to compare against.
17-
//
18-
// Unix 0 for an EST timezone is not equivalent to a UTC timezone.
19-
UnixZero = time.Unix(0, 0).UTC()
20-
)
15+
// UnixZero sets the zero unix UTC timestamp we want to compare against.
16+
//
17+
// Unix 0 for an EST timezone is not equivalent to a UTC timezone.
18+
var UnixZero = time.Unix(0, 0).UTC()
2119

2220
func init() {
2321
dt := DateTime{}

time_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
{[]byte("2014-12-15T08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
2828
{[]byte("2014-12-15T08:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
2929
{[]byte("2014-12-15T08:00Z"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
30-
{[]byte("2018-01-28T23:54Z"), time.Date(2018, 01, 28, 23, 54, 0, 0, time.UTC), "2018-01-28T23:54:00.000Z", "2018-01-28T23:54:00.000Z"},
30+
{[]byte("2018-01-28T23:54Z"), time.Date(2018, 0o1, 28, 23, 54, 0, 0, time.UTC), "2018-01-28T23:54:00.000Z", "2018-01-28T23:54:00.000Z"},
3131
{[]byte("2014-12-15T08:00:00.000Z"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
3232
{[]byte("2011-08-18T19:03:37.123000000+01:00"), time.Date(2011, 8, 18, 19, 3, 37, 123*1e6, p.Location()), "2011-08-18T19:03:37.123+01:00", "2011-08-18T18:03:37.123Z"},
3333
{[]byte("2011-08-18T19:03:37.123000+0100"), time.Date(2011, 8, 18, 19, 3, 37, 123*1e6, p.Location()), "2011-08-18T19:03:37.123+01:00", "2011-08-18T18:03:37.123Z"},
@@ -134,8 +134,8 @@ func TestDateTime_IsDateTime_errorCases(t *testing.T) {
134134

135135
v = IsDateTime("1972-12-31T23:59:60.000Z")
136136
assert.False(t, v)
137-
138137
}
138+
139139
func TestDateTime_UnmarshalText_errorCases(t *testing.T) {
140140
pp := NewDateTime()
141141
err := pp.UnmarshalText([]byte("yada"))
@@ -159,6 +159,7 @@ func TestDateTime_UnmarshalText(t *testing.T) {
159159

160160
}
161161
}
162+
162163
func TestDateTime_UnmarshalJSON(t *testing.T) {
163164
for caseNum, example := range testCases {
164165
t.Logf("Case #%d", caseNum)
@@ -199,6 +200,7 @@ func TestDateTime_MarshalText(t *testing.T) {
199200
assert.Equal(t, []byte(example.str), mt)
200201
}
201202
}
203+
202204
func TestDateTime_MarshalJSON(t *testing.T) {
203205
for caseNum, example := range testCases {
204206
t.Logf("Case #%d", caseNum)
@@ -208,6 +210,7 @@ func TestDateTime_MarshalJSON(t *testing.T) {
208210
assert.Equal(t, esc([]byte(example.str)), bb)
209211
}
210212
}
213+
211214
func TestDateTime_MarshalJSON_Override(t *testing.T) {
212215
oldNormalizeMarshal := NormalizeTimeForMarshal
213216
defer func() {

0 commit comments

Comments
 (0)