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

`pk` will bw found always because of the above if condition. Though what you say also works. I'll see to it.