Skip to content

Commit 518f224

Browse files
committed
Fix issues with merged tickets
A function, convertTimeToInt64 was removed, so the code that it used to use was added directly. CRUD tests were having issues with int64 vs int32. The new extended JSON implementation returns int32's by default and we were comparing with int64's. Change-Id: I4fd5b57e971db8c2c81441df31c103bb97750f63
1 parent 9744704 commit 518f224

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

bson/constructor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func (ElementConstructor) DateTime(key string, dt int64) *Element {
331331
// Time creates a datetime element with the given key and value.
332332
func (c ElementConstructor) Time(key string, t time.Time) *Element {
333333
// Apply nanoseconds to milliseconds conversion
334-
return c.DateTime(key, convertTimeToInt64(t))
334+
return c.DateTime(key, t.Unix()*1000+int64(t.Nanosecond()/1e6))
335335
}
336336

337337
// Null creates a null element with the given key.

mongo/crud_util_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import (
1010
"bytes"
1111
"context"
1212
"encoding/json"
13-
"github.com/mongodb/mongo-go-driver/bson/bsoncodec"
1413
"math"
1514
"strings"
1615
"testing"
1716

17+
"github.com/mongodb/mongo-go-driver/bson/bsoncodec"
18+
1819
"github.com/mongodb/mongo-go-driver/bson"
1920
"github.com/mongodb/mongo-go-driver/core/readconcern"
2021
"github.com/mongodb/mongo-go-driver/core/writeconcern"
@@ -570,7 +571,7 @@ func verifyBulkWriteResult(t *testing.T, res *BulkWriteResult, result json.RawMe
570571
// replace floats with ints
571572
for opID, upsertID := range expected.UpsertedIDs {
572573
if floatID, ok := upsertID.(float64); ok {
573-
expected.UpsertedIDs[opID] = int64(floatID)
574+
expected.UpsertedIDs[opID] = int32(floatID)
574575
}
575576
}
576577

0 commit comments

Comments
 (0)