Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(searchPlugin): ensure search updates are unique to collection #6363

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from

Conversation

lynndylanhurley
Copy link

@lynndylanhurley lynndylanhurley commented May 15, 2024

Description

Our app is using the searchPlugin with two different collections. We were having issues with search results disappearing randomly when we saved certain records.

After digging in, we found that the syncWithSearch hook is only searching for matching search records by id, not relationTo.

This resulted in the syncWithSearch hook incorrectly overwriting records in the wrong collection if they share the same ID. This patch resolves the issue.

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes

## Description

Our app is using the `searchPlugin` with two different collections. We were having issues with search results disappearing randomly when we saved certain records.

After digging in, we found that the `syncWithSearch` hook is only searching for matching `search` records by `id`, not `relationTo`.

This resulted in the `syncWithSearch` hook incorrectly overwriting records in the wrong collection if they share the same ID. This patch resolves the issue.

- [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository.

## Type of change

<!-- Please delete options that are not relevant. -->

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] Existing test suite passes locally with my changes
- [ ] I have made corresponding changes to the documentation
@lynndylanhurley
Copy link
Author

I did run the test suite locally but it seems to be failing for other unrelated reasons

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.

None yet

1 participant