BSON Support#2518
Merged
stephenberry merged 7 commits intomainfrom Apr 23, 2026
Merged
Conversation
FNV-1a 64-bit constant 14695981039346656037ULL overflows size_t when size_t is 32 bits. Branch on sizeof(size_t) and use the standard 32-bit FNV-1a constants (offset 2166136261, prime 16777619) on narrow platforms. 64-bit path is unchanged.
|
One of the tests failed for cec1cb3. @admin check logs https://download.copr.fedorainfracloud.org/results/packit/stephenberry-glaze-2518/fedora-rawhide-s390x/10349916-glaze/builder-live.log, packit dashboard https://dashboard.packit.dev/jobs/copr/3492077 and external service dashboard https://copr.fedorainfracloud.org/coprs/build/10349916/ |
- docs/bson.md: rewrite glz::uuid section. Old text claimed every Glaze format supported it and that the reader accepted subtype 0x03 for legacy interop; both contradict the code (only BSON has a specialization, and read.hpp rejects 0x03 as driver-ambiguous). - write.hpp: drop debug-only asserts on embedded NUL in cstring keys and regex pattern/options. The asymmetric debug-vs-release behavior was confusing; a downstream read already surfaces the malformed wire as syntax_error, matching the JSON/BEVE pattern. - read.hpp + bson_to_json.hpp: attach "trailing bytes after document terminator" to the exact-fill syntax_error so both entry points produce the same diagnostic. - write.hpp: rewrite enum comment to stop implying reflect_enums is honored on BSON and to spell out the interop-driven reason it isn't.
- header.hpp: add constexpr to regex/javascript/binary operator== so the std::string/std::vector-backed helper types match the consistency of object_id/datetime/timestamp. All supported compilers (C++23 with GCC 13+, Clang 18+, current MSVC) provide constexpr std::string and std::vector equality. - docs/bson.md + read.hpp: document the std::string_view target lifetime rule. The reader aliases into the input buffer for non-assignable targets, so the buffer must outlive every decoded view. Added a Strings section to the docs and a pointer-comment at the reader site. - tests/bson_test: fill coverage gaps flagged in review. Added glz::meta-annotated struct tests (renamed keys round-trip, wire bytes carry the mapped names, nested meta structs) and two uint64 boundary tests (INT64_MAX+1 rejected with invalid_length, INT64_MAX itself accepted) to lock in the integer write-path contracts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
glz::bson::object_id,datetime,regex,javascript,decimal128,timestamp,binary,min_key,max_key) for BSON wire types that have no native JSON equivalentglz::bson_to_jsonconverter producing MongoDB Canonical Extended JSON v2, plus a skip path that advances past deprecated BSON types (undefined, DBPointer, symbol, code-with-scope) without erroringskip_null_members, matching the struct-writer behaviorTest plan
bson_to_jsonconverter coverage for all supported types, depth-limit enforcement, and trailing-byte rejection