Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Summary

Spotted an inconsistency in how text indexes are handled in schema.indexes(). schema.indexes() incorrectly modifies state that future calls depend on, so without this fix, the first schema.index() call will correctly return { content: 'text' } but the 2nd would return { content: 1 }

Examples

@vkarpov15 vkarpov15 added this to the 8.19.3 milestone Oct 22, 2025
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

This PR fixes a bug where schema.indexes() incorrectly cached text indexes. The issue caused subsequent calls to return { content: 1 } instead of the correct { content: 'text' } because the function was modifying the original index object instead of creating a copy.

  • Fixed mutation of cached index objects by creating a shallow copy of the options object
  • Added test coverage to verify text indexes are correctly retained across multiple schema.indexes() calls

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/helpers/schema/getIndexes.js Added object spread operator to create a copy of the index options, preventing mutation of cached data
test/schema.test.js Added test case verifying that text indexes maintain their 'text' type across multiple schema.indexes() calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vkarpov15 vkarpov15 merged commit 3df7bbf into master Oct 24, 2025
74 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/get-indexes-fix branch October 24, 2025 14:39
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.

3 participants