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