def set_rights(self, entity_id, related_entity_id, right=None, ignore_user=False):
        if not entity_id or not related_entity_id:
            return

        if ignore_user == True:
            user_id = None
        else:
            if not self.__user_id:
                return
            user_id = self.__user_id

        if type(entity_id) is not list:
            entity_id = [entity_id]

        if type(related_entity_id) is not list:
            related_entity_id = [related_entity_id]

        sql = """
            UPDATE relationship SET
                deleted = NOW(),
                is_deleted = 1,
                deleted_by = %%s
            WHERE is_deleted = 0
            AND relationship_definition_keyname IN ('viewer', 'expander', 'editor', 'owner')
            AND entity_id IN (%s)
            AND related_entity_id IN (%s);
        """ % (','.join(map(str, entity_id)), ','.join(map(str, related_entity_id)))
        self.db_execute(sql, user_id)

        if ['viewer', 'expander', 'editor', 'owner'] in right:
            for e in entity_id:
                for re in related_entity_id:
                    self.db_execute('INSERT INTO relationship SET relationship_definition_keyname = %s, entity_id = %s, related_entity_id = %s, created = NOW(), created_by = %s;', right, int(e), int(re), user_id)

        self.db_execute('UPDATE entity SET changed = NOW() WHERE entity.id IN (%s);' % ','.join(map(str, entity_id)))
dataset/ETHPy150Open argoroots/Entu/app/main/db.py/Entity.set_rights/swapped operands of `in`