Repository navigation
This release fixes how the legacy query API (the BSON-based find, count and update) handles some edge cases. Since 4.0.0 it has run on libmongoc 2, which removed the old C calls, and in these cases it accepted bad input silently or dropped options.
Fixes
-
Invalid
$querydocuments are rejected. These were accepted silently before; libmongoc 1.x's legacy find rejected both, and so does 4.0.3. (#33)- A
$querythat isn't a document, such as{$query: 5}, madefind()andcount()match every document. - Fields that don't start with
$next to$querywere merged into the filter.
Now
count()returns an error,find()returnsniland GridFSlist(filter:)throws. A duplicate$querymeans the last one wins, as it did in 1.x. - A
-
count()applies more legacy-query options.$hint,$maxTimeMS,$commentand$collationwere silently dropped before; they now apply. (#33) -
Negative
limitincount(). It now counts like a positive limit, as the oldcountcommand treated it. Before, the server rejected it. (#33) -
update(selector:update:flag: .multiUpdate)with a replacement document is an error. Before, it replaced one document and reported success. Use an update-operator document such as{$set: …}to update many. (#33)
Behaviour to note
count()runs as an aggregate$match, so the query can't use$where,$nearor$nearSphere; use$expr, or$geoWithinwith$center/$centerSphere. This has been the case since 4.0.0; it's now documented.- Code that relied on any of the silent behaviours above will now see an error or
nilinstead.
No API changes. Tested against MongoDB 8.3 and 8 with libmongoc 2.5.5 on macOS and Linux, and in CI with apt's libmongoc 2.2.2 on Ubuntu 26.04. Full changes: 4.0.2...4.0.3