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

Can't filter objects with missing custom fields values #795

Closed
david-kn opened this issue Aug 10, 2021 · 2 comments · Fixed by #1434
Closed

Can't filter objects with missing custom fields values #795

david-kn opened this issue Aug 10, 2021 · 2 comments · Fixed by #1434
Assignees
Labels
type: feature Introduction of new or enhanced functionality to the application
Milestone

Comments

@david-kn
Copy link
Contributor

david-kn commented Aug 10, 2021

Environment

  • Python version: Any
  • Nautobot version: 1.1.1

Any objects (let's say prefixes) with custom fields can't be filtered any more to search those with missing values.

  • When filtering objects with missing value(s) in standard attributes, a value null is used (e.g. /api/ipam/prefixes/?site=null ) - works just fine (OK)
  • When filtering objects with missing value(s) in custom fields, I used to use value "0" (zero) which worked well but it does not anymore (e.g. /api/ipam/prefixes/?my_custom_field=0 ) and neither does value null or empty string or anything else.

Steps to Reproduce

  1. Let's have objects with custom fields (e.g. my_custom_field ) where some are not filled in
  2. Try to filter only those objects where the custom field is not filled in: /api/ipam/prefixes/?my_custom_field=0

Expected behaviour

The objects with missing (empty) value in a given custom fields should have been returned.

Observed Behavior

No objects were returned at all.

@glennmatthews glennmatthews added status: under review type: bug Something isn't working as expected labels Aug 12, 2021
@nniehoff
Copy link
Contributor

nniehoff commented Aug 16, 2021

To clarify this a bit this is specifically the case for custom fields of type Selection. The previous query of ?my_custom_field=0 used to work in NetBox as the query appears to be the index of the choices array with 0 being null. In Nautobot custom fields were refactored and now the URL query specifies the value of the field so the same query is looking for the literal value of 0 not null. While this does seem to be specifically related to the selection field type it seems like being able to query any custom field for null/empty should be a valid query somehow.

@bryanculver
Copy link
Member

Merged into next.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new or enhanced functionality to the application
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants