Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1534,12 +1534,25 @@ func (idxs indexSlice) Swap(i, j int) { idxs[i], idxs[j] = idxs[j], idxs[i]

func simpleIndexKey(realKey bson.D) (key []string) {
for i := range realKey {
var vi int
field := realKey[i].Name
vi, ok := realKey[i].Value.(int)
if !ok {

switch realKey[i].Value.(type) {
case int64:
vf, _ := realKey[i].Value.(int64)
vi = int(vf)
case float64:
vf, _ := realKey[i].Value.(float64)
vi = int(vf)
case string:
if vs, ok := realKey[i].Value.(string); ok {
key = append(key, "$"+vs+":"+field)
continue
}
case int:
vi = realKey[i].Value.(int)
}

if vi == 1 {
key = append(key, field)
continue
Expand All @@ -1548,10 +1561,6 @@ func simpleIndexKey(realKey bson.D) (key []string) {
key = append(key, "-"+field)
continue
}
if vs, ok := realKey[i].Value.(string); ok {
key = append(key, "$"+vs+":"+field)
continue
}
panic("Got unknown index key type for field " + field)
}
return
Expand Down