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

you could write the negation of the condition in the `if`, and raise the error if condition is `True` (avoids the `pass` and the `else`.