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

Searches on related fields (can) cause duplicate results #111

Open
sjamaan opened this issue Jan 7, 2019 · 1 comment
Open

Searches on related fields (can) cause duplicate results #111

sjamaan opened this issue Jan 7, 2019 · 1 comment

Comments

@sjamaan
Copy link
Contributor

sjamaan commented Jan 7, 2019

When using search for related fields that end in multiple records, binder may return the same record more than once, depending on circumstances.

The same issue also happens when using a Q() object in a permission filter that traverses a relation into a "many" side.

Example (untested yet):

  • Add searches = ['animals__name__icontains'] to CaretakerView
  • Set up a caretaker with multiple animals under his care
  • Search for a substring that contains multiple animals
  • Result has more than one caretaker record with the same id
@sjamaan sjamaan changed the title searches on related fields (can) cause duplicate results Searches on related fields (can) cause duplicate results Jan 7, 2019
@sjamaan
Copy link
Contributor Author

sjamaan commented Jan 7, 2019

My current workaround involves crafting a custom search() method which adds an Exists annotation and searches on that, instead.

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

No branches or pull requests

1 participant