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

Custom field objects sort by ID rather than what they display #10721

Closed
neuro42 opened this issue Oct 21, 2022 · 3 comments
Closed

Custom field objects sort by ID rather than what they display #10721

neuro42 opened this issue Oct 21, 2022 · 3 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@neuro42
Copy link

neuro42 commented Oct 21, 2022

NetBox version

v3.3.6

Python version

3.9

Steps to Reproduce

  1. Add a custom field
    1. Model: IPAM > prefix
    2. Name: gateway
    3. Type: object
    4. Object type: IPAM > IP address
  2. Add some IP addresses (being out of sorted order)
    1. 172.16.42.1/24
    2. 172.16.10.1/24
    3. 172.16.128.1/24
    4. 172.16.6.1/24
  3. Add some prefixes, using the added IP address objects for the custom gateway field
    1. 172.16.42.0/24 w/ 172.16.42.1/24
    2. 172.16.10.0/24 w/ 172.16.10.1/24
    3. 172.16.128.0/24 w/ 172.16.128.1/24
    4. 172.16.6.0/24 w/ 172.16.6.1/24
  4. View the prefix list, and configure the table to include the custom gateway field
  5. click on the gateway column header to sort by the custom field

Expected Behavior

Gateway column to be in sorted IP address order:
172.16.6.1/24
172.16.10.1/24
172.16.42.1/24
172.16.128.1/24

Observed Behavior

Gateway column is sorted by object id (creation order):
172.16.42.1/24
172.16.10.1/24
172.16.128.1/24
172.16.6.1/24

Non-custom columns (eg: site) are sorted by their name, and not their ID

@neuro42 neuro42 added the type: bug A confirmed report of unexpected behavior in the application label Oct 21, 2022
@jeremystretch
Copy link
Member

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Oct 25, 2022
@neuro42
Copy link
Author

neuro42 commented Oct 28, 2022

Steps to reproduce rewritten

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: revisions needed This issue requires additional information to be actionable labels Oct 31, 2022
@arthanson arthanson self-assigned this Nov 4, 2022
@arthanson
Copy link
Collaborator

Unfortunately, this isn't really easily supportable with the way custom-fields are implemented. The issue here is that for object-type custom fields the ID of the object is stored so it is basically a generic-foreign-key, so the sorting is happening on the ID (which would be the creation order). It would not be straight-forward to de-reference this to the object and sort on the appropriate sub-field in a performant way for the list. After discussion we will probably look at disabling sorting on this if the custom-field is an object or multi-object type.

@arthanson arthanson removed their assignment Nov 17, 2022
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Nov 17, 2022
@jeremystretch jeremystretch self-assigned this Nov 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
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: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants