You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--- a/netbox/dcim/models.py
+++ b/netbox/dcim/models.py
@@ -806,10 +806,10 @@ class InterfaceManager(models.Manager):
}[method]
return queryset.extra(select={
'_name': "SUBSTRING({} FROM '^([^0-9]+)')".format(sql_col),
- '_slot': "CAST(SUBSTRING({} FROM '([0-9]+)\/[0-9]+\/[0-9]+(:[0-9]+)?$') AS integer)".format(sql_col),
- '_subslot': "CAST(SUBSTRING({} FROM '([0-9]+)\/[0-9]+(:[0-9]+)?$') AS integer)".format(sql_col),
- '_position': "CAST(SUBSTRING({} FROM '([0-9]+)(:[0-9]+)?$') AS integer)".format(sql_col),
- '_channel': "CAST(SUBSTRING({} FROM ':([0-9]+)$') AS integer)".format(sql_col),
+ '_slot': "CAST(SUBSTRING({} FROM '([0-9]+)\/[0-9]+\/[0-9]+([.:][0-9]+)?$') AS integer)".format(sql_col),
+ '_subslot': "CAST(SUBSTRING({} FROM '([0-9]+)\/[0-9]+([.:][0-9]+)?$') AS integer)".format(sql_col),
+ '_position': "CAST(SUBSTRING({} FROM '([0-9]+)([.:][0-9]+)?$') AS integer)".format(sql_col),
+ '_channel': "CAST(SUBSTRING({} FROM '[.:]([0-9]+)$') AS integer)".format(sql_col),
}).order_by(*ordering)
Modify the query to order by nulls first for each component. I don't know enough python/django to do this, but the feature is there in django and postgres.
The text was updated successfully, but these errors were encountered:
The above fixes most of the ordering problems. It doesn't address e.g. GigabitEthernet0 being ordered after GigabitEthernet0/0/0, but that's likely going to require rewriting the entire ordering scheme. It looks like Django 1.11 might make this easier than in the past, but it's not a priority right now.
Issue type: bug report
Python version: 2.7.9
NetBox version: v2.0-beta2
I have created VLAN subInterfaces on my Cisco IOS-XE gear and represent them in NetBox. They don't sort as expected. I use the Alphabetic sort order.
Here is an example:
My specific concerns are:
GigabitEthernet0/0/2.2
is not beforeGigabitEthernet0/0/3
GigabitEthernet0/0/1.117
is beforeGigabitEthernet0/0/0.120
GigabitEthernet0
is not beforeGigabitEthernet0/0/0
There are two changes that I believe would solve these problems without negatively affecting other cases.
':([0-9]+)$'
becomes'[.:]([0-9]+)$'
https://github.com/digitalocean/netbox/blob/v2-develop/netbox/dcim/models.py#L809
The text was updated successfully, but these errors were encountered: