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

UI filter forms should filter by numeric ID rather than by slug #5894

Closed
jeremystretch opened this issue Feb 27, 2021 · 0 comments
Closed

UI filter forms should filter by numeric ID rather than by slug #5894

jeremystretch opened this issue Feb 27, 2021 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Milestone

Comments

@jeremystretch
Copy link
Member

jeremystretch commented Feb 27, 2021

Proposed Changes

Currently, when filtering a list of objects within the NetBox web UI, many of the provided search fields apply a query filter based on the selected object's slug. For example, filtering for all devices in a site with the slug raleigh4 would apply the query parameter ?site=raleigh-4.

This issue proposes changing all such fields to reference the related object by its numeric ID instead. For example, the above query would become ?site_id=123, where 123 is the site's primary key.

To be clear, this does not change the behavior of the actual filters, and will not have any effect on external consumers of the REST API. It merely changes which of the existing filters NetBox's own UI uses.

Justification

Although more human-friendly, filtering by a related object's slug field requires a SQL JOIN when making the database query to pull in the related object:

SELECT DISTINCT ...
  FROM "dcim_device"
 INNER JOIN "dcim_site"
    ON ("dcim_device"."site_id" = "dcim_site"."id")
 WHERE "dcim_site"."slug" = 'raleigh4'
 ORDER BY "dcim_device"."_name" ASC, "dcim_device"."id" ASC

Filtering by the related object's ID does not require a JOIN, because that value is stored in the filtered object's foreign key field.

@jeremystretch jeremystretch added type: housekeeping Changes to the application which do not directly impact the end user status: under review Further discussion is needed to determine this issue's scope and/or implementation status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Feb 27, 2021
@jeremystretch jeremystretch added this to the v2.11 milestone Mar 1, 2021
@jeremystretch jeremystretch self-assigned this Mar 1, 2021
jeremystretch added a commit that referenced this issue Mar 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Projects
None yet
Development

No branches or pull requests

1 participant