@staticmethod
def _where_builder(filters, case):
    """
        Build where part for query
        :param filters: dict filters for rows (where)
        :return: str update query and dict where data
        """
    query = ''
    where_data = {}
    for key in filters:
        if isinstance(filters[key], tuple):
            if len(filters[key]) == 3:
                if '=' in filters[key][2]:
                    query += (key + ' >= ' + '%(where_start_' + key +
                        ')s AND ' + key + ' <= ' + '%(where_end_' + key +
                        ')s ' + case + ' ')
                else:
                    query += (key + ' > ' + '%(where_start_' + key +
                        ')s AND ' + key + ' < ' + '%(where_end_' + key +
                        ')s ' + case + ' ')
                where_data['start_' + key] = filters[key][0]
                where_data['end_' + key] = filters[key][1]
            elif len(filters[key]) == 2:
                if not filters[key][0]:
                    query += key + ' ' + filters[key][1
                        ] + ' ' + 'NULL ' + case + ' '
                else:
                    query += key + ' ' + filters[key][1
                        ] + ' ' + '%(where_' + key + ')s ' + case + ' '
                    where_data[key] = filters[key][0]
            else:
                raise ValueError('Missing case param in filter: %s' %
                    filters[key][0])
        elif not filters[key] and not isinstance(filters[key], int):
            query += key + ' is NULL ' + case + ' '
        else:
            query += key + ' = ' + '%(where_' + key + ')s ' + case + ' '
            where_data[key] = filters[key]
    return query.rstrip(case + ' '), where_data
