Skip to content

Commit 9eec9e3

Browse files
committed
CDRIVER-302 fix pass through params in aggregate
collection_aggregate failed to properly pass options through. Fix that handling which allows for explain with aggregate
1 parent c177b50 commit 9eec9e3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/mongoc/mongoc-collection.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,6 @@ mongoc_collection_aggregate (mongoc_collection_t *collection, /* IN */
314314
did_batch_size = true;
315315
batch_size = (int32_t)bson_iter_as_int64 (&iter);
316316
BSON_APPEND_INT32 (&child, "batchSize", batch_size);
317-
} else if (BSON_ITER_IS_KEY (&iter, "allowDiskUse") &&
318-
BSON_ITER_HOLDS_BOOL (&iter)) {
319-
BSON_APPEND_BOOL (&child, "allowDiskUse",
320-
bson_iter_bool (&iter));
321-
} else {
322-
/*
323-
* Just pass it through if we don't know what it is.
324-
*/
325-
bson_append_iter (&child, bson_iter_key (&iter), -1, &iter);
326317
}
327318
}
328319
}
@@ -334,6 +325,14 @@ mongoc_collection_aggregate (mongoc_collection_t *collection, /* IN */
334325
bson_append_document_end (&command, &child);
335326
}
336327

328+
if (options && bson_iter_init (&iter, options)) {
329+
while (bson_iter_next (&iter)) {
330+
if (! (BSON_ITER_IS_KEY (&iter, "batchSize") || BSON_ITER_IS_KEY (&iter, "cursor"))) {
331+
bson_append_iter (&command, bson_iter_key (&iter), -1, &iter);
332+
}
333+
}
334+
}
335+
337336
cursor = mongoc_collection_command (collection, flags, 0, 0, batch_size,
338337
&command, NULL, read_prefs);
339338

0 commit comments

Comments
 (0)