Skip to content

feat: fetch() includeVector parameter + upstream nullable normalization (closes #192) - #202

Merged
s2x merged 3 commits into
mainfrom
feat/issue-192-fetch-include-vector
Aug 28, 2026
Merged

feat: fetch() includeVector parameter + upstream nullable normalization (closes #192)#202
s2x merged 3 commits into
mainfrom
feat/issue-192-fetch-include-vector

Conversation

@s2x

@s2x s2x commented Aug 28, 2026

Copy link
Copy Markdown
Member

Description

Closes #192

Two changes to fetch(), mirroring the upstream zvec C API:

  1. includeVector named argument (default true, BC-compatible): pass includeVector: false to omit vector data from fetched documents. The other query paths (query(), queryWithReranker(), queryByDocId(), groupByQuery()) already exposed this — fetch() was the odd one out.
  2. Nullable-field normalization: the FFI wrapper now mirrors upstream 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_fetch gains int include_vector (0/1, wrapper convention), passed as bool to Fetch(); static normalize_nullable_fields_for_fetch() applied after Fetch() when c->Schema() succeeds (silently skipped on schema failure, matching upstream)
  • src/ZVec.php: fetch() captures includeVector from 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 in test_fetch_output_fields.phpt, expectation update in test_doc_enhanced.phpt (nullable field now present-null after fetch — correct-by-design)
  • README.md API reference, CHANGELOG.md ([Unreleased] Added + Changed), docs/helpers/ knowledge base entries

Testing

  • Builds locally (./build_ffi.sh, zvec v0.6.0)
  • All .phpt tests pass: 182 tests — 178 passed, 0 failed, 2 platform skips, 2 expected XFAILs (php run-tests.php -n tests/)
  • No test database leftovers (test_dbs/ empty)

Code Review

  • Passed subagent code review (2 rounds; all findings addressed — README API reference, knowledge-base qualification, extra test error-path assertions, CHANGELOG entries)

Notes for release

  • The shared-library ABI changed (zvec_collection_fetch gained a parameter) — the versioned prebuilt libzvec_ffi.so artifact must be republished at release time, or Linux composer installs will crash on fetch().

Piotr Hałas 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
@s2x s2x self-assigned this Aug 28, 2026
@s2x
s2x merged commit 200f263 into main Aug 28, 2026
3 checks passed
@s2x
s2x deleted the feat/issue-192-fetch-include-vector branch August 28, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch(): expose includeVector + mirror upstream nullable normalization

1 participant