Skip to content

v1.7.0 - 2026-10-18

Choose a tag to compare

@al-mehedi al-mehedi released this 18 Oct 11:52
· 2 commits to main since this release

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 by bsonToJsonString().
  • Direct BSON-to-structure cursor decoding - Iterator.next() no longer converts documents through JSON; supports nested structs, arrays, tagged unions and jsonic-style field defaults.
  • indexModelCreateCompound() - Creates a compound index model over multiple fields with individual sort orders.
  • Collection.renameWith() - Renames a collection with an optional drop_target flag to overwrite the destination.

Changed

  • bsonAddProp() and bsonSetProp() 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 with bsonFreeJson() instead of heap.free().
  • bsonBuild() formatted input limit is now 4096 bytes (was 8192); use bsonBuildLarge() for larger input.
  • Driver initialization/cleanup is reference-counted, allowing multiple Mongo instances to coexist.
  • indexModelCreate() builds key/option documents directly instead of parsing JSON.
  • indexModelCreate() and indexModelCreateCompound() return Error.OutOfMemory instead 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() and aggregate() now return an error instead of a null cursor.
  • hasCollection() now distinguishes a failed existence check from a missing collection.
  • drop() now reports OperationFailed instead of the misleading DoesNotExists.
  • resetPool() now returns Error.OperationFailed and 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 concurrent Mongo instances; 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.