Skip to content

Commit

Permalink
Fix issues with merged tickets
Browse files Browse the repository at this point in the history
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
  • Loading branch information
skriptble committed Oct 11, 2018
1 parent 9744704 commit 518f224
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bson/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (ElementConstructor) DateTime(key string, dt int64) *Element {
// Time creates a datetime element with the given key and value.
func (c ElementConstructor) Time(key string, t time.Time) *Element {
// Apply nanoseconds to milliseconds conversion
return c.DateTime(key, convertTimeToInt64(t))
return c.DateTime(key, t.Unix()*1000+int64(t.Nanosecond()/1e6))
}

// Null creates a null element with the given key.
Expand Down
5 changes: 3 additions & 2 deletions mongo/crud_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/mongodb/mongo-go-driver/bson/bsoncodec"
"math"
"strings"
"testing"

"github.com/mongodb/mongo-go-driver/bson/bsoncodec"

"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/core/readconcern"
"github.com/mongodb/mongo-go-driver/core/writeconcern"
Expand Down Expand Up @@ -570,7 +571,7 @@ func verifyBulkWriteResult(t *testing.T, res *BulkWriteResult, result json.RawMe
// replace floats with ints
for opID, upsertID := range expected.UpsertedIDs {
if floatID, ok := upsertID.(float64); ok {
expected.UpsertedIDs[opID] = int64(floatID)
expected.UpsertedIDs[opID] = int32(floatID)
}
}

Expand Down

0 comments on commit 518f224

Please sign in to comment.