Skip to content

fix(model): handle passing string projection to hydrate()#16088

Open
vkarpov15 wants to merge 2 commits intomasterfrom
vkarpov15/gh-16082
Open

fix(model): handle passing string projection to hydrate()#16088
vkarpov15 wants to merge 2 commits intomasterfrom
vkarpov15/gh-16082

Conversation

@vkarpov15
Copy link
Collaborator

Fix #16082

Summary

Quick fix for Model.hydrate(): use parseProjection() with no retainMinusPaths to handle string and array of string projections. Both docs and TypeScript types indicate Model.hydrate() supports string|string[] as projection argument, so runtime should support that too.

Examples

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Model.hydrate() runtime handling for projection when passed as a string or string[], aligning behavior with the documented/typed API and preventing incorrect projection application.

Changes:

  • Normalize hydrate()’s projection using parseProjection() before applying it.
  • Expand hydrate() projection tests to cover object, string (exclusive), and string[] (inclusive) forms.
  • Minor refactor in parseProjection() implementation (charAt() / slice()).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/model.js Parses projection in Model.hydrate() to correctly support string / string-array projections before applyProjection() and model creation.
test/model.hydrate.test.js Adds coverage ensuring hydrate() respects object, string, and string[] projection inputs without marking docs modified.
lib/helpers/projection/parseProjection.js Small internal implementation tweak used by hydrate() to convert string/array projections to an object form.

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.

Model.hydrate() does not handle string/array projection parameter correctly, despite JSDoc allowing it

3 participants