Skip to content

Introduce explicit index field matching methods#5192

Open
DragonFSKY wants to merge 1 commit intospring-projects:mainfrom
DragonFSKY:GH-5187
Open

Introduce explicit index field matching methods#5192
DragonFSKY wants to merge 1 commit intospring-projects:mainfrom
DragonFSKY:GH-5187

Conversation

@DragonFSKY
Copy link
Copy Markdown

Closes #5187

This PR follows the defensive path proposed in the issue discussion for IndexInfo.isIndexForFields(Collection<String>).

The existing method is deprecated but keeps its current subset-matching behavior for compatibility. The PR introduces explicit alternatives for the different matching semantics:

  • containsAllFields(Collection<String>) for subset matching regardless of index field position
  • isIndexForFieldsExactly(Collection<String>) for exact field-name matching regardless of order
  • coversFields(Collection<String>) for compound-index prefix coverage

It also updates an internal test helper to use containsAllFields(Collection<String>) instead of the deprecated method.

Tested with:

./mvnw -s settings.xml -pl spring-data-mongodb clean test -Dtest=IndexInfoUnitTests

Checklist:

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided by the project and have not submitted unrelated formatting changes.
  • You submit test cases that back your changes.
  • You added yourself as author in the headers of the classes you touched.

Closes spring-projects#5187

Signed-off-by: dragonfsky <dragonfsky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexInfo::isIndexForFields returns false positives

2 participants