@@ -21,8 +21,7 @@ import (
21
21
"github.com/mongodb/mongo-go-driver/bson/bsonrw"
22
22
"github.com/mongodb/mongo-go-driver/bson/bsonrw/bsonrwtest"
23
23
"github.com/mongodb/mongo-go-driver/bson/bsontype"
24
- "github.com/mongodb/mongo-go-driver/bson/decimal"
25
- "github.com/mongodb/mongo-go-driver/bson/objectid"
24
+ "github.com/mongodb/mongo-go-driver/bson/primitive"
26
25
"github.com/mongodb/mongo-go-driver/x/bsonx/bsoncore"
27
26
)
28
27
@@ -50,7 +49,7 @@ func TestDefaultValueDecoders(t *testing.T) {
50
49
intAllowedDecodeTypes := []interface {}{(* int8 )(nil ), (* int16 )(nil ), (* int32 )(nil ), (* int64 )(nil ), (* int )(nil )}
51
50
uintAllowedDecodeTypes := []interface {}{(* uint8 )(nil ), (* uint16 )(nil ), (* uint32 )(nil ), (* uint64 )(nil ), (* uint )(nil )}
52
51
now := time .Now ().Truncate (time .Millisecond )
53
- d128 := decimal .NewDecimal128 (12345 , 67890 )
52
+ d128 := primitive .NewDecimal128 (12345 , 67890 )
54
53
var ptrPtrValueUnmarshaler * * testValueUnmarshaler
55
54
var ptrPtrUnmarshaler * * testUnmarshaler
56
55
@@ -809,31 +808,31 @@ func TestDefaultValueDecoders(t *testing.T) {
809
808
nil ,
810
809
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .ObjectID },
811
810
bsonrwtest .Nothing ,
812
- ValueDecoderError {Name : "ObjectIDDecodeValue" , Types : []interface {}{(* objectid .ObjectID )(nil )}, Received : & wrong },
811
+ ValueDecoderError {Name : "ObjectIDDecodeValue" , Types : []interface {}{(* primitive .ObjectID )(nil )}, Received : & wrong },
813
812
},
814
813
{
815
814
"type not objectID" ,
816
- objectid .ObjectID {},
815
+ primitive .ObjectID {},
817
816
nil ,
818
817
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .String },
819
818
bsonrwtest .Nothing ,
820
819
fmt .Errorf ("cannot decode %v into an ObjectID" , bsontype .String ),
821
820
},
822
821
{
823
822
"ReadObjectID Error" ,
824
- objectid .ObjectID {},
823
+ primitive .ObjectID {},
825
824
nil ,
826
825
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .ObjectID , Err : errors .New ("roid error" ), ErrAfter : bsonrwtest .ReadObjectID },
827
826
bsonrwtest .ReadObjectID ,
828
827
errors .New ("roid error" ),
829
828
},
830
829
{
831
830
"success" ,
832
- objectid .ObjectID {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C },
831
+ primitive .ObjectID {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C },
833
832
nil ,
834
833
& bsonrwtest.ValueReaderWriter {
835
834
BSONType : bsontype .ObjectID ,
836
- Return : objectid .ObjectID {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C },
835
+ Return : primitive .ObjectID {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C },
837
836
},
838
837
bsonrwtest .ReadObjectID ,
839
838
nil ,
@@ -850,19 +849,19 @@ func TestDefaultValueDecoders(t *testing.T) {
850
849
nil ,
851
850
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .Decimal128 },
852
851
bsonrwtest .Nothing ,
853
- ValueDecoderError {Name : "Decimal128DecodeValue" , Types : []interface {}{(* decimal .Decimal128 )(nil )}, Received : & wrong },
852
+ ValueDecoderError {Name : "Decimal128DecodeValue" , Types : []interface {}{(* primitive .Decimal128 )(nil )}, Received : & wrong },
854
853
},
855
854
{
856
855
"type not decimal128" ,
857
- decimal .Decimal128 {},
856
+ primitive .Decimal128 {},
858
857
nil ,
859
858
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .String },
860
859
bsonrwtest .Nothing ,
861
- fmt .Errorf ("cannot decode %v into a decimal .Decimal128" , bsontype .String ),
860
+ fmt .Errorf ("cannot decode %v into a primitive .Decimal128" , bsontype .String ),
862
861
},
863
862
{
864
863
"ReadDecimal128 Error" ,
865
- decimal .Decimal128 {},
864
+ primitive .Decimal128 {},
866
865
nil ,
867
866
& bsonrwtest.ValueReaderWriter {BSONType : bsontype .Decimal128 , Err : errors .New ("rd128 error" ), ErrAfter : bsonrwtest .ReadDecimal128 },
868
867
bsonrwtest .ReadDecimal128 ,
@@ -1293,8 +1292,8 @@ func TestDefaultValueDecoders(t *testing.T) {
1293
1292
})
1294
1293
1295
1294
t .Run ("success path" , func (t * testing.T ) {
1296
- oid := objectid . New ()
1297
- oids := []objectid .ObjectID {objectid . New (), objectid . New (), objectid . New ()}
1295
+ oid := primitive . NewObjectID ()
1296
+ oids := []primitive .ObjectID {primitive . NewObjectID (), primitive . NewObjectID (), primitive . NewObjectID ()}
1298
1297
var str = new (string )
1299
1298
* str = "bar"
1300
1299
now := time .Now ().Truncate (time .Millisecond )
@@ -1303,7 +1302,7 @@ func TestDefaultValueDecoders(t *testing.T) {
1303
1302
t .Errorf ("Error parsing URL: %v" , err )
1304
1303
t .FailNow ()
1305
1304
}
1306
- decimal128 , err := decimal .ParseDecimal128 ("1.5e10" )
1305
+ decimal128 , err := primitive .ParseDecimal128 ("1.5e10" )
1307
1306
if err != nil {
1308
1307
t .Errorf ("Error parsing decimal128: %v" , err )
1309
1308
t .FailNow ()
@@ -1327,8 +1326,8 @@ func TestDefaultValueDecoders(t *testing.T) {
1327
1326
nil ,
1328
1327
},
1329
1328
{
1330
- "map[string]objectid .ObjectID" ,
1331
- map [string ]objectid .ObjectID {"foo" : oid },
1329
+ "map[string]primitive .ObjectID" ,
1330
+ map [string ]primitive .ObjectID {"foo" : oid },
1332
1331
func () []byte {
1333
1332
idx , doc := bsoncore .AppendDocumentStart (nil )
1334
1333
doc = bsoncore .AppendObjectIDElement (doc , "foo" , oid )
@@ -1348,8 +1347,8 @@ func TestDefaultValueDecoders(t *testing.T) {
1348
1347
nil ,
1349
1348
},
1350
1349
{
1351
- "map[string][]objectid .ObjectID" ,
1352
- map [string ][]objectid .ObjectID {"Z" : oids },
1350
+ "map[string][]primitive .ObjectID" ,
1351
+ map [string ][]primitive .ObjectID {"Z" : oids },
1353
1352
buildDocumentArray (func (doc []byte ) []byte {
1354
1353
doc = bsoncore .AppendObjectIDElement (doc , "0" , oids [0 ])
1355
1354
doc = bsoncore .AppendObjectIDElement (doc , "1" , oids [1 ])
@@ -1384,8 +1383,8 @@ func TestDefaultValueDecoders(t *testing.T) {
1384
1383
nil ,
1385
1384
},
1386
1385
{
1387
- "map[string][]decimal .Decimal128" ,
1388
- map [string ][]decimal .Decimal128 {"Z" : {decimal128 }},
1386
+ "map[string][]primitive .Decimal128" ,
1387
+ map [string ][]primitive .Decimal128 {"Z" : {decimal128 }},
1389
1388
buildDocumentArray (func (doc []byte ) []byte {
1390
1389
return bsoncore .AppendDecimal128Element (doc , "0" , decimal128 )
1391
1390
}),
@@ -1511,13 +1510,13 @@ func TestDefaultValueDecoders(t *testing.T) {
1511
1510
L struct {
1512
1511
M string
1513
1512
}
1514
- Q objectid .ObjectID
1513
+ Q primitive .ObjectID
1515
1514
T []struct {}
1516
1515
Y json.Number
1517
1516
Z time.Time
1518
1517
AA json.Number
1519
1518
AB * url.URL
1520
- AC decimal .Decimal128
1519
+ AC primitive .Decimal128
1521
1520
AD * time.Time
1522
1521
AE * testValueUnmarshaler
1523
1522
}{
@@ -1590,15 +1589,15 @@ func TestDefaultValueDecoders(t *testing.T) {
1590
1589
M string
1591
1590
}
1592
1591
N [][]string
1593
- R []objectid .ObjectID
1592
+ R []primitive .ObjectID
1594
1593
T []struct {}
1595
1594
W []map [string ]struct {}
1596
1595
X []map [string ]struct {}
1597
1596
Y []map [string ]struct {}
1598
1597
Z []time.Time
1599
1598
AA []json.Number
1600
1599
AB []* url.URL
1601
- AC []decimal .Decimal128
1600
+ AC []primitive .Decimal128
1602
1601
AD []* time.Time
1603
1602
AE []* testValueUnmarshaler
1604
1603
}{
@@ -1628,7 +1627,7 @@ func TestDefaultValueDecoders(t *testing.T) {
1628
1627
Z : []time.Time {now , now },
1629
1628
AA : []json.Number {json .Number ("5" ), json .Number ("10.1" )},
1630
1629
AB : []* url.URL {murl },
1631
- AC : []decimal .Decimal128 {decimal128 },
1630
+ AC : []primitive .Decimal128 {decimal128 },
1632
1631
AD : []* time.Time {& now , & now },
1633
1632
AE : []* testValueUnmarshaler {
1634
1633
{t : bsontype .String , val : bsoncore .AppendString (nil , "hello" )},
0 commit comments