def build_like(operator="AND", **kwargs):
    """Generates an SQL WHERE string.

    Will replace None's with IS NULL's.

    Keyword Args:
       Containing SQL search string
       Eg: ``{"foo": "x", "bar": None}``

    Returns:
        Tuple containing string that can
        be used after LIKE in SQL statement,
        along with a list of the values.
        Eg. ("foo like ? AND bar IS NULL", [ "x%" ])

    """
    vals = []
    query = []
    for k in kwargs:
        if kwargs[k] is None:
            query.append(k + " IS NULL")
        else:
            query.append(k + " LIKE ?")
            vals.append(kwargs[k] + '%')

    if query:
        return ((" %s " % operator).join(query), vals)
    else:
        return (None, [])