Repository navigation
v1.7.0 - 2026-10-18
Major performance and correctness overhaul: direct BSON encoding/decoding, copy-free property appends and several memory/race bug fixes, better documentation, and Zig-0.17.0 version support.
Added
toBsonDoc()- Converts a Zig structure (including nested structs, arrays, tagged unions and optionals) directly into a BSON document.bsonFreeJson()- Frees strings returned bybsonToJsonString().- Direct BSON-to-structure cursor decoding -
Iterator.next()no longer converts documents through JSON; supports nested structs, arrays, tagged unions andjsonic-style field defaults. indexModelCreateCompound()- Creates a compound index model over multiple fields with individual sort orders.Collection.renameWith()- Renames a collection with an optionaldrop_targetflag to overwrite the destination.
Changed
bsonAddProp()andbsonSetProp()no longer require an allocator; keys and string values are appended by length without intermediate copies.bsonToJsonString()no longer requires an allocator and returns a driver-owned string; free it withbsonFreeJson()instead ofheap.free().bsonBuild()formatted input limit is now 4096 bytes (was 8192); usebsonBuildLarge()for larger input.- Driver initialization/cleanup is reference-counted, allowing multiple
Mongoinstances to coexist. indexModelCreate()builds key/option documents directly instead of parsing JSON.indexModelCreate()andindexModelCreateCompound()returnError.OutOfMemoryinstead of a NULL model handle when the driver fails to allocate the model.deleteIndex()treats an already-missing index or collection as a successful no-op (server codes 26/27).- The BSON decoder no longer rejects integer types wider than the IEEE 754 2^53 boundary at compile time; instead, fractional doubles error out and double-typed values beyond the 2^53 exact-integer range error out for such types (int32/int64-typed values remain exact).
Fixed
- Double-free / use-after-free in
Iterator.next()(documents are cursor-owned and ephemeral). - Memory leak of the
count_documents()reply. - Memory leaks in
bsonBuild()/bsonBuildLarge()error paths. - Silent empty-document bug in
bsonBuild()when parsing failed with debug mode disabled. - Race condition in
resetPool()(pool access is now mutex-protected). find(),findIndexes()andaggregate()now return an error instead of a null cursor.hasCollection()now distinguishes a failed existence check from a missing collection.drop()now reportsOperationFailedinstead of the misleadingDoesNotExists.resetPool()now returnsError.OperationFailedand keeps the previous pool intact instead of storing a NULL pool when replacement fails.- Driver
init()/cleanUp()and the global log handler are now mutex-protected, closing init/cleanup and log-handler races between concurrentMongoinstances; the handler is only installed/uninstalled by the first/last debug-mode instance. insertMany()guards against a NULL BSON document on allocation failure and treats empty input as a successful no-op.