Correct sorting of IP addresses to be numeric not alpha #3888
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The IP column sorting function on the automation-> discovered devices is not working when single sorting the column after the page has been loaded once. I was able to see that this is the area of the code that was dropping the INET_ATON from the order by query.
Notes from wrong commit to develop instead of 1.2.x:
This change allows for sort to work properly when sorting on the Automation-> Discovered Devices page using the IP address column. What would happen is when sorting by the IP address field the sort would look like the following:
The INET_ATON was not getting applied when sorting just by the IP address column. It would work when first going to the page after sorting by IP but if attempting to sort while staying on the page it would drop the INET_ATON(ip) to be just ip. It was also working properly when multi-sorting. This seems to only be an issue when clicking on the sort of the IP address column.
I attempted to follow the other places where this code looks to have been run to come up with a similar solutions.
TheWitness replied:
This isn't quite right, you have to inspect the entirety of the sort list which becomes problematic with multi-column sort. This has to be given some thought. It should also be against the 1.2.x branch an not develop.
In response I can see that the multisort happens in the next if statement below the one that I am editing. From what I can tell that if statement where I did make the changes would not work with a multisort as I think it is only when the columns are reset or only doing one column sort action at a time.
I have a couple print statements with the sort query and the full SQL query above the table. I also have a flag to let me know which if statement I am in.
That image is being sorted on the hostname column but it is the same idea. As you can see the INET_ATON(hostname) is not there. Which in a multisort or the initial load of the page it drops down to the third if statement in the block of code from 779-813.
Thanks