Fixes: #17358 - Ensure correct comparison of overlapping IPRanges
Fixes: #17358
Adds new Lookup classes for lt/gt/lte/gte comparisons with INET objects, ignoring the mask. This enables correct comparison of adjacent IPRanges when looking for overlaps, and prevents acceptance of an invalid new IPRange where the entered start_address and end_address masks do not match the existing ranges.
I don't think that works actually; the Host transform only casts the input value to a HOST (i.e. HOST(%s)), but in order to compare to a bare IP address on the rhs you have to cast it to an INET e.g. CAST(HOST(%s) AS INET). I don't think Transform supports that kind of structure unless I'm missing something.
At any rate the comparisons in my unit test fail and it throws an overlapping exception when trying to add 1.2.3.100/24-1.2.3.199/24 (it says it overlaps with 1.2.3.1-99/24).
That's why I created the four specific comparison lookups in the first place, because using HOST on its own leads to incorrect comparisons.
... (30 minutes later) ...
After some more digging into the Transform class, I've added a HostAsInet Transform that does what we would need for this lookup using the start_address__host_as_inet__gte lookup syntax. If you like this we can use it instead of the four specific lookups I did earlier (and remove those).
This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken.