One bug we fixed here a while ago was when hosts existed without IP addresses, we'd be searching where `ip IS NULL`.  It looks like this change might reintroduce the bug, as we could generate a search for:

    WHERE ip IS NULL OR name = 'foo.example.com'

Which could return the first (random) host without an IP address.