cast ip value to string before using string methods

necessary since the value may be an IPAddr (eg when using a native ip address type in postgres)