docs: def generalize_sql(sql):
      """
      Removes most variables from an SQL query and replaces them with X or N for numbers.
  
      Based on Mediawiki's DatabaseBase::generalizeSQL
  
      :type sql str|None
      :rtype: str
      """
      if sql is None:
          return None
  
      # multiple spaces
      sql = re.sub(r'\s{2,}', ' ', sql)
  
      # MW comments
      # e.g. /* CategoryDataService::getMostVisited N.N.N.N */
      sql = remove_comments_from_sql(sql)
  
      # handle LIKE statements
      sql = normalize_likes(sql)
  
      sql = re.sub(r"\\\\", '', sql)
      sql = re.sub(r"\\'", '', sql)
      sql = re.sub(r'\\"', '', sql)
      sql = re.sub(r"'[^\']*'", 'X', sql)
      sql = re.sub(r'"[^\"]*"', 'X', sql)
  
      # All newlines, tabs, etc replaced by single space
      sql = re.sub(r'\s+', ' ', sql)
  
      # All numbers => N
      sql = re.sub(r'-?[0-9]+', 'N', sql)
  
      # WHERE foo IN ('880987','882618','708228','522330')
      sql = re.sub(r' (IN|VALUES)\s*\([^,]+,[^)]+\)', ' \\1 (XYZ)', sql, flags=re.IGNORECASE)
  
      return sql.strip()