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

Thanks rpbarlow for suggestion, loic, akaariai, and jorgecarleitao for review.