Fixed #14334 -- Query comparision now check for object types.

Please refer to my comments on the PR for reasons to change this.