Problem/Motivation
The example query shown on the module page does not seem to work for Drupal 8+
Steps to reproduce
I have created a new content type "institution" and added an IP address field "field_institution_ip_range".
I have tried rewriting the example query for Drupal 9 as shown below. It executes without error, but it fails to find any matches
$visitor_addr = ip2long(Drupal::request()->getClientIp());
$query = Drupal::entityQuery('node')
->condition('type', 'institution')
->condition('status', 1)
->condition('field_institution_ip_range.ip_start', $visitor_addr, '<=')
->condition('field_institution_ip_range.ip_end', $visitor_addr, '>=')
->execute();
I can execute an SQL query against the Drupal database using my current IP address and do indeed find a match.
SELECT DISTINCT entity_id
FROM node__field_institution_ip_range
WHERE
field_institution_ip_range_ip_start <= INET6_ATON(MY_IP_ADDRESS) AND
field_institution_ip_range_ip_end >= INET6_ATON(MY_IP_ADDRESS)
Proposed resolution
Could the documentation be updated with an example for Drupal 8+ please?