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

Filtering By Related Tree Models With Non-Unique Names Can Return Unexpected Results #4329

Closed
bryanculver opened this issue Aug 25, 2023 · 2 comments
Assignees
Labels
emergent Unplanned work that is brought into a sprint after it's started. type: bug Something isn't working as expected

Comments

@bryanculver
Copy link
Member

          Additional unexpected behavior transforms filtering of parent locations into the parent name and the name of all descendants in the tree (as opposed to the actual descendants in the tree). For example, having the following Location Tree:
Region 1
  Site 1
Region 2
  Site 1
  Site 2

and using the filter {"location": ["Region 2"]}

Would result in location__name__in=["Region 2", "Site 1", "Site 2"]

I would expect this to be location__in=[<LocationRegion1>,<LocationSite1>,<LocationSite2>]

Originally posted by @jmcgill298 in #4207 (comment)

@bryanculver bryanculver added type: bug Something isn't working as expected emergent Unplanned work that is brought into a sprint after it's started. labels Aug 25, 2023
@bryanculver
Copy link
Member Author

Example:
image

@bryanculver bryanculver self-assigned this Aug 25, 2023
bryanculver added a commit that referenced this issue Aug 28, 2023
* Fix #4329 by using pk of the descendants.

* Update nautobot/core/tests/test_filters.py

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>

* Update changes/4329.fixed

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>

* Update nautobot/core/filters.py

---------

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
@bryanculver
Copy link
Member Author

Closed via #4330

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emergent Unplanned work that is brought into a sprint after it's started. type: bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant