Fixed #14334 -- Query relation lookups now check object types.

Should this use `isinstance(collections.Iterable)` or similar?