Skip to content

Commit 5ba52d9

Browse files
committed
fixes
1 parent d94dead commit 5ba52d9

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

internal/integration/unified/bulkwrite_helpers.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ func createBulkWriteModel(rawModel bson.Raw) (mongo.WriteModel, error) {
103103
return nil, fmt.Errorf("error creating update: %w", err)
104104
}
105105
case "sort":
106-
sort, err := createSort(val)
107-
if err != nil {
108-
return nil, fmt.Errorf("error creating sort: %w", err)
109-
}
110-
uom.SetSort(sort)
106+
uom.SetSort(val.Document())
111107
case "upsert":
112108
uom.SetUpsert(val.Boolean())
113109
default:
@@ -256,11 +252,7 @@ func createBulkWriteModel(rawModel bson.Raw) (mongo.WriteModel, error) {
256252
}
257253
rom.SetHint(hint)
258254
case "sort":
259-
sort, err := createSort(val)
260-
if err != nil {
261-
return nil, fmt.Errorf("error creating sort: %w", err)
262-
}
263-
rom.SetSort(sort)
255+
rom.SetSort(val.Document())
264256
case "replacement":
265257
replacement = val.Document()
266258
case "upsert":

internal/integration/unified/collection_operation_execution.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,11 +1292,7 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes
12921292
}
12931293
opts.SetHint(hint)
12941294
case "sort":
1295-
sort, err := createSort(val)
1296-
if err != nil {
1297-
return nil, fmt.Errorf("error creating sort: %w", err)
1298-
}
1299-
opts.SetSort(sort)
1295+
opts.SetSort(val.Document())
13001296
case "replacement":
13011297
replacement = val.Document()
13021298
case "upsert":

internal/integration/unified/crud_helpers.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,3 @@ func createHint(val bson.RawValue) (interface{}, error) {
214214
}
215215
return hint, nil
216216
}
217-
218-
func createSort(val bson.RawValue) (interface{}, error) {
219-
var sort interface{}
220-
221-
switch val.Type {
222-
case bson.TypeEmbeddedDocument:
223-
sort = val.Document()
224-
default:
225-
return nil, fmt.Errorf("unrecognized sort value type %s", val.Type)
226-
}
227-
return sort, nil
228-
}

mongo/bulk_write_models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (rom *ReplaceOneModel) SetUpsert(upsert bool) *ReplaceOneModel {
178178
// matched by the sort order will be replaced. This option is only valid for MongoDB versions >= 8.0. The driver will
179179
// return an error if the sort parameter is a multi-key map. The default value is nil.
180180
func (rom *ReplaceOneModel) SetSort(sort interface{}) *ReplaceOneModel {
181-
rom.Sort = &sort
181+
rom.Sort = sort
182182
return rom
183183
}
184184

0 commit comments

Comments
 (0)