-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.3.2, 1.3.3
-
Component/s: CRUD
-
None
-
Environment:when use multi field to sort, probably different results
type AB struct
{ A int32 bson:"A" B int32 bson:"B" }func TestSort(t *testing.T) {
mongodb.Init()
defer mongodb.Close()
mongodb.GetTrainingDB().Collection("TestSort").Drop(context.Background())
for i := 0; i < 5; i++ {
mongodb.GetTrainingDB().Collection("TestSort").InsertOne(context.Background(), bson.M
)
mongodb.GetTrainingDB().Collection("TestSort").InsertOne(context.Background(), bson.M
)
}
for i := 0; i < 100; i++ {
sortABList := []AB{}
theOption := options.Find().SetSort(bson.M
)
theCur, _ := mongodb.GetTrainingDB().Collection("TestSort").Find(context.Background(), bson.M{}, theOption)
defer theCur.Close(context.Background())
for theCur.Next(context.Background())
{ var theValue AB theCur.Decode(&theValue) sortABList = append(sortABList, theValue) } for i := 0; i < len(sortABList)-1; i++ {
fmt.Println(sortABList[i])
if sortABList[i].A < sortABList[i+1].A
}
fmt.Println()
}
}