feat: fetch() includeVector parameter + upstream nullable normalization (closes #192) - #202
Merged
Merged
Conversation
added 3 commits
August 28, 2026 21:09
#192) - Add include_vector param to zvec_collection_fetch (ffi/zvec_ffi.h, ffi/zvec_ffi_php.h, ffi/zvec_ffi.cc) - Port upstream normalize_nullable_fields_for_fetch: missing nullable fields now returned as explicit null instead of absent key (parity with official C API) - PHP fetch(): named-arg includeVector (default true, BC-compatible) - New tests/test_fetch_include_vector.phpt (11 scenarios) - Update stale comment in test_fetch_output_fields.phpt; adjust test_doc_enhanced.phpt expectation for new fetch null semantics - Knowledge base entries in docs/helpers/
- README.md: document includeVector named arg in fetch() API reference - docs/helpers: qualify named-arg coercion claim (weak-mode string coercion vs strict_types=1 TypeError) - test_fetch_include_vector: add non-bool includeVector error-path assertion and array-form-without-outputFields scenario
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.
Description
Closes #192
Two changes to
fetch(), mirroring the upstream zvec C API:includeVectornamed argument (defaulttrue, BC-compatible): passincludeVector: falseto omit vector data from fetched documents. The other query paths (query(),queryWithReranker(),queryByDocId(),groupByQuery()) already exposed this —fetch()was the odd one out.normalize_nullable_fields_for_fetch(c_api.cc:7024-7050) — unset nullable fields are returned as present-with-null (hasField()→true,isFieldNull()→true, typed getters →null) instead of a missing key. Non-nullable absent fields continue to be omitted.Changes
ffi/zvec_ffi.h,ffi/zvec_ffi_php.h,ffi/zvec_ffi.cc:zvec_collection_fetchgainsint include_vector(0/1, wrapper convention), passed asbooltoFetch(); staticnormalize_nullable_fields_for_fetch()applied afterFetch()whenc->Schema()succeeds (silently skipped on schema failure, matching upstream)src/ZVec.php:fetch()capturesincludeVectorfrom the variadic as a named argument (PHP grammar forbids params after a variadic;array|string|bool ...+is_bool()validation rejects positional bools)tests/test_fetch_include_vector.phpt(new, 13 scenarios incl. error paths), stale comment fix intest_fetch_output_fields.phpt, expectation update intest_doc_enhanced.phpt(nullable field now present-null after fetch — correct-by-design)Testing
./build_ffi.sh, zvec v0.6.0)php run-tests.php -n tests/)test_dbs/empty)Code Review
Notes for release
zvec_collection_fetchgained a parameter) — the versioned prebuiltlibzvec_ffi.soartifact must be republished at release time, or Linux composer installs will crash onfetch().