Sample Header Ad - 728x90

Postgres inet array contains a single ip

5 votes
2 answers
5013 views
Requirement: user can add single ips or ip address ranges to a database table(for example permissions table having ipAddresses of inet[] type). I need to query that a single ip is contained in the array of ipAddresses field which can be array of ip addresses or ip address ranges or both. I have tried to add where query like this: WHERE "ipAddresses" @> '192.168.1.5'::inet and also like this WHERE "ipAddresses" >> '192.168.1.5'::inet but no luck. Thanks in advance. id uuid NOT NULL gen_random_uuid() permissions uuid[] ipAddresses inet[] createdAt timestamp with time zone now() updatedAt timestamp with time zone now() source: pg array functions and pg network address functions
Asked by Radio Active (177 rep)
Jul 21, 2017, 08:16 AM
Last activity: Jul 21, 2017, 10:52 AM