(self, model, name_prefix='', name_infix='',
                                      name_suffix='', select_name_only=False)
return query
Customize query based on given name filtering criteria.

        Instead of django.db filter operator, we use customized query is
        due to the following issue. django.db always translates string
        filter query by using "LIKE BINARY". Unfortunately, LIKE BINARY
        does not respect the index for the field with varchar data type.

        Args:
            model: django db model that contains table's information
            name_prefix: name starts with this string
            name_infix: name contains this string
            name_suffix: name ends with this string
            select_name_only: only return name in the query result

        Returns:
            Customized query
Customize query based on given name filtering criteria.
Customize query based on given name filtering criteria .
def _customized_name_filter_query(self, model, name_prefix='', name_infix='',
                                      name_suffix='', select_name_only=False):
        """ Customize query based on given name filtering criteria.

        Instead of django.db filter operator, we use customized query is
        due to the following issue. django.db always translates string
        filter query by using "LIKE BINARY". Unfortunately, LIKE BINARY
        does not respect the index for the field with varchar data type.

        Args:
            model: django db model that contains table's information
            name_prefix: name starts with this string
            name_infix: name contains this string
            name_suffix: name ends with this string
            select_name_only: only return name in the query result

        Returns:
            Customized query
        """
        query_template = 'SELECT %s FROM %s %s;'
        selector = 'name' if select_name_only else '*'
        where_condition = ''
        conditions = []
        if name_prefix != '':
            conditions.append('name LIKE "%s%%%%"' % name_prefix.replace('_', '\_'))
        if name_infix != '':
            conditions.append('name LIKE "%%%%%s%%%%"' % name_infix.replace('_', '\_'))
        if name_suffix != '':
            conditions.append('name LIKE "%%%%%s"' % name_suffix.replace('_', '\_'))
        if conditions:
            where_condition = 'WHERE ' + ' AND '.join(conditions)

        query = query_template % (selector, model.get_table_name(), where_condition)
        return query
def _customized_name_filter_query ( self , model , name_prefix = '' , name_infix = '' , name_suffix = '' , select_name_only = False ) : query_template = 'SELECT %s FROM %s %s;' selector = 'name' if select_name_only else '*' where_condition = '' conditions = [ ] if name_prefix != '' : conditions . append ( 'name LIKE "%s%%%%"' % name_prefix . replace ( '_' , '\_' ) ) if name_infix != '' : conditions . append ( 'name LIKE "%%%%%s%%%%"' % name_infix . replace ( '_' , '\_' ) ) if name_suffix != '' : conditions . append ( 'name LIKE "%%%%%s"' % name_suffix . replace ( '_' , '\_' ) ) if conditions : where_condition = 'WHERE ' + ' AND ' . join ( conditions ) query = query_template % ( selector , model . get_table_name ( ) , where_condition ) return query