-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4.0
-
Component/s: libmongoc
-
None
-
Fully Compatible
New function takes options expressed as a free-form BSON document. Paves the way to a more flexible future API in which we can add support for arbitrary options without API expansions.
mongoc_cursor_t * mongoc_collection_find_with_opts (mongoc_collection_t *collection, const bson_t *filter, const bson_t *opts, const mongoc_read_prefs_t *read_prefs);
The plan:
- mongoc_collection_find_with_opts translates to old-style _mongoc_cursor_new call with all the old parameters - done
- readConcern is prohibited - specs say drivers MAY allow it per-operation, we only allow it to be set on client, db, and collection, so let's not support it per-operation right now, and enforce that choice - done
- Test mongoc_collection_find_with_opts for the same scenarios as mongoc_collection_find - ensure it handles all the same server-specific cases (wire version, OP_QUERY vs "find" command, mongos vs mongod) - done
- Add "filter" and "opts" to mongoc_cursor_t struct. mongoc_collection_find_with_opts copies its "filter" and "opts" parameters to these fields of the mongoc_cursor_t - done
- When "filter" and "opts" are set, use them in the "find" command path instead of constructing from old fields in the mongoc_cursor_t - done
- When "filter" and "opts" are set, rewrite the OP_QUERY path to use them instead of the old fields (the work done for Step 1 is reusable here) - done
- Deal with maxAwaitTimeMS and test it with mongoc_collection_find_with_opts - done
- _mongoc_cursor_new drops its qflags, skip, limit, batch_size, fields, and read_concern parameters, gains an "opts" parameter. mongoc_collection_find_with_opts now calls it directly. mongoc_collection_find translates from its parameters to an "opts" document; e.g., batch_size=1 becomes {batchSize: 1}. Other _mongoc_cursor_new callers are also updated to create "opts" documents. - done
- Test that unrecognized opts fields are sent to server unmodified - done
- Delete old fields from mongoc_cursor_t struct: fields, write_concern, flags, skip, limit, batch_size, max_await_time_ms - done
- Update docs and NEWS - done
- Update signature for consistency with mongoc_collection_count_with_opts: (collection, filter, opts, read_prefs) - done
- Make the common strings like "awaitData" into macros - done
- Call _mongoc_cursor_new_with opts internally from mongoc_client_command, mongoc_client_find_databases, mongoc_collection_find, mongoc_cursor_new_from_command_reply, mongoc_database_find_collections - done
- Test _mongoc_n_return some more, it's been a bug factory in the past - done
- is depended on by
-
DRIVERS-347 Support deprecated "modifiers" FindOption in CRUD API
- Closed
-
PHPC-783 Use mongoc_collection_find_with_opts() for Query execution
- Closed
-
CDRIVER-1528 Deprecate mongoc_collection_find
- Closed
-
CDRIVER-1539 Consider additional "opts" validation
- Closed
- is related to
-
CDRIVER-1751 mongoc_collection_find_with_opts() should return error if collation specified and connection does not support read commands
- Closed
- related to
-
CDRIVER-1554 Redundant handling of $query in _translate_query_opt()
- Closed