def __get_id_list(self, entity_id=None, search=None, entity_definition_keyname=None, limit=None, only_public=False, sharing_key=None):
        """
        Get list of Entity IDs. entity_id, entity_definition_keyname and user_id can be single ID or list of IDs.

        """

        select_parts = ['e.id AS id']
        join_parts = []
        where_parts = ['e.is_deleted = 0']
        sql_parts = []

        if search != None:
            i = 0
            for s in search.split(' ')[:5]:
                if not s:
                    continue
                i += 1
                join_parts.append('RIGHT JOIN property AS p%(idx)i ON p%(idx)i.entity_id = e.id RIGHT JOIN property_definition AS ppd%(idx)i ON ppd%(idx)i.keyname = p%(idx)i.property_definition_keyname AND ppd%(idx)i.search = 1' % {'idx': i})

                if not self.__user_id or only_public == True:
                    join_parts.append('LEFT JOIN property_definition AS pd%i ON pd%i.keyname = p%i.property_definition_keyname' % (i, i, i))

                where_parts.append('p%i.value_display LIKE \'%%%%%s%%%%\'' % (i, s))
                where_parts.append('p%i.is_deleted = 0' % i)

        if entity_definition_keyname != None:
            if type(entity_definition_keyname) is not list:
                entity_definition_keyname = [entity_definition_keyname]
            where_parts.append('e.entity_definition_keyname IN (%s)' % ','.join(['\'%s\'' % x for x in map(str, entity_definition_keyname)]))

        if entity_id != None:
            if type(entity_id) is not list:
                entity_id = [entity_id]
            where_parts.append('e.id IN (%s)' % ','.join(map(str, entity_id)))

        if self.__user_id and only_public == False:
            where_parts.append('r.is_deleted = 0')
            join_parts.append('RIGHT JOIN relationship AS r  ON r.entity_id  = e.id')
            where_parts.append('(r.related_entity_id = %s AND r.relationship_definition_keyname IN (\'viewer\', \'expander\', \'editor\', \'owner\') OR e.sharing IN (\'domain\', \'public\'))' % self.__user_id)
        elif sharing_key:
            where_parts.append('e.sharing_key = \'%s\'' % sharing_key)
        else:
            where_parts.append('e.sharing = \'public\'')
            i = 0
            if search != None:
                for s in search.split(' '):
                    i += 1
                    where_parts.append('pd%i.public = 1' % i)

        if len(select_parts) > 0:
            sql_parts.append('SELECT DISTINCT %s' % ', '.join(select_parts))

        sql_parts.append(' FROM entity AS e')

        if len(join_parts) > 0:
            sql_parts.append(' %s' %  ' '.join(join_parts))

        if len(where_parts) > 0:
            sql_parts.append(' WHERE %s' % ' AND '.join(where_parts))

        if limit:
            limit = limit % ' LIMIT %s'
        else:
            limit = ''

        sql_parts.append(' ORDER BY e.sort, e.created DESC%s;' % limit)

        sql = ''.join(sql_parts)
        # logging.debug(sql)

        items = self.db_query(sql)
        if not items:
            return []
        return [x.get('id') for x in items]

    # def formula_properties(self, entity_id):
    #     sql = """
    #         SELECT *
    #         FROM property p
    #         WHERE p.entity_id = %s
    #         AND p.value_formula is not null
    #         AND p.is_deleted = 0
    #         ORDER BY p.id
    #         ;""" % entity_id
    #     # logging.debug(sql)
    #     return self.db_query(sql)
dataset/ETHPy150Open argoroots/Entu/app/main/db.py/Entity.__get_id_list/swapped operands of `%`