Allow count queries to work on relations.