Fixes the `Relation#exists?` to work with polymorphic associations.

Fixes #15821.