-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v2.11.7
Python version
3.7
Steps to Reproduce
- Create a prefix (like 10.1.0.0/24)
- Create new custom field "date_test", type Date, assign it to prefixes
- Create another prefix (like 10.1.1.0/24)
- Create third prefix (like 10.1.2.0/24), with a date (like "2021-07-01")
- In the prefixes list in GUI select the "Date testing" field as a column
- See the prefixes with the "Date testing" values: the first two prefixes show "—" while the third prefix show the date "2021-07-01"
- Sort by the "Date testing" column by clicking the column header "Date testing"
Expected Behavior
It is expected that the prefix list is sorted so that the prefix with the date (10.1.2.0/24) would be at the bottom of the list (assuming that empty date is "smaller" than any date), i.e. the order would be
- 10.1.0.0/24: —
- 10.1.1.0/24: —
- 10.1.2.0/24: 2021-07-01
Observed Behavior
The prefixes are ordered like this:
- 10.1.1.0/24: —
- 10.1.2.0/24: 2021-07-01
- 10.1.0.0/24: —
In the database the prefixes have the following custom_field_data values:
- 10.1.0.0/24:
{} - 10.1.1.0/24:
{"date_test": null} - 10.1.2.0/24:
{"date_test": "2021-07-01"}
So it looks like the null value is treated differently to the missing custom field value.
Obviously this only affects installations where the custom field is added after populating the data.
Workaround is to populate null values manually in the database, using the jsonb operators in PostgreSQL I believe.
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application