@@ -72,7 +72,7 @@ func executeCount(sess *sessionImpl, coll *Collection, args map[string]interface
72
72
case "limit" :
73
73
opts = opts .SetLimit (int64 (opt .(float64 )))
74
74
case "collation" :
75
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
75
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
76
76
}
77
77
}
78
78
@@ -98,7 +98,7 @@ func executeDistinct(sess *sessionImpl, coll *Collection, args map[string]interf
98
98
case "fieldName" :
99
99
fieldName = opt .(string )
100
100
case "collation" :
101
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
101
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
102
102
}
103
103
}
104
104
@@ -317,7 +317,7 @@ func executeDeleteOne(sess *sessionImpl, coll *Collection, args map[string]inter
317
317
case "filter" :
318
318
filter = opt .(map [string ]interface {})
319
319
case "collation" :
320
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
320
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
321
321
}
322
322
}
323
323
@@ -346,7 +346,7 @@ func executeDeleteMany(sess *sessionImpl, coll *Collection, args map[string]inte
346
346
case "filter" :
347
347
filter = opt .(map [string ]interface {})
348
348
case "collation" :
349
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
349
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
350
350
}
351
351
}
352
352
@@ -380,7 +380,7 @@ func executeReplaceOne(sess *sessionImpl, coll *Collection, args map[string]inte
380
380
case "upsert" :
381
381
opts = opts .SetUpsert (opt .(bool ))
382
382
case "collation" :
383
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
383
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
384
384
}
385
385
}
386
386
@@ -423,7 +423,7 @@ func executeUpdateOne(sess *sessionImpl, coll *Collection, args map[string]inter
423
423
case "upsert" :
424
424
opts = opts .SetUpsert (opt .(bool ))
425
425
case "collation" :
426
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
426
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
427
427
}
428
428
}
429
429
@@ -463,7 +463,7 @@ func executeUpdateMany(sess *sessionImpl, coll *Collection, args map[string]inte
463
463
case "upsert" :
464
464
opts = opts .SetUpsert (opt .(bool ))
465
465
case "collation" :
466
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
466
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
467
467
}
468
468
}
469
469
@@ -498,7 +498,7 @@ func executeAggregate(sess *sessionImpl, coll *Collection, args map[string]inter
498
498
case "batchSize" :
499
499
opts = opts .SetBatchSize (int32 (opt .(float64 )))
500
500
case "collation" :
501
- opts = opts .SetCollation (newCollationFromMap (opt .(map [string ]interface {})))
501
+ opts = opts .SetCollation (collationFromMap (opt .(map [string ]interface {})))
502
502
}
503
503
}
504
504
@@ -824,46 +824,8 @@ func collationFromMap(m map[string]interface{}) *options.Collation {
824
824
collation .MaxVariable = maxVariable .(string )
825
825
}
826
826
827
- if backwards , found := m ["backwards" ]; found {
828
- collation .Backwards = backwards .(bool )
829
- }
830
-
831
- return & collation
832
- }
833
-
834
- // Matt: bad name, I know; also, type-aliasing, I know.
835
- // The issue is, options.Collation has a ToDocument function and mongoopt.Collation has a convert function
836
- // type aliasing doesn't allow defining new functions on non-local types.
837
- // When all options are updated to the improved api, this function will be the only one and will simply be named "collationFromMap"
838
- func newCollationFromMap (m map [string ]interface {}) * options.Collation {
839
- var collation options.Collation
840
-
841
- if locale , found := m ["locale" ]; found {
842
- collation .Locale = locale .(string )
843
- }
844
-
845
- if caseLevel , found := m ["caseLevel" ]; found {
846
- collation .CaseLevel = caseLevel .(bool )
847
- }
848
-
849
- if caseFirst , found := m ["caseFirst" ]; found {
850
- collation .CaseFirst = caseFirst .(string )
851
- }
852
-
853
- if strength , found := m ["strength" ]; found {
854
- collation .Strength = int (strength .(float64 ))
855
- }
856
-
857
- if numericOrdering , found := m ["numericOrdering" ]; found {
858
- collation .NumericOrdering = numericOrdering .(bool )
859
- }
860
-
861
- if alternate , found := m ["alternate" ]; found {
862
- collation .Alternate = alternate .(string )
863
- }
864
-
865
- if maxVariable , found := m ["maxVariable" ]; found {
866
- collation .MaxVariable = maxVariable .(string )
827
+ if normalization , found := m ["normalization" ]; found {
828
+ collation .Normalization = normalization .(bool )
867
829
}
868
830
869
831
if backwards , found := m ["backwards" ]; found {
0 commit comments