def get_relation_count_query(self, query, parent):
        if parent.get_query().from__ == query.get_query().from__:
            return self.get_relation_count_query_for_self_join(query, parent)

        self._set_join(query)

        return super(BelongsToMany, self).get_relation_count_query(query, parent)
Add the constraints for a relationship count query.
dataset/ETHPy150Open sdispater/orator/orator/orm/relations/belongs_to_many.py/BelongsToMany.get_relation_count_query