Program: 183667
Project: 183667
Buggy source:
/** 
 * Build an SQL query string from the given clauses.
 * @param distinct true if you want each row to be unique, false otherwise.
 * @param tables The table names to compile the query against.
 * @param columns A list of which columns to return. Passing null willreturn all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
 * @param where A filter declaring which rows to return, formatted as an SQLWHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URL.
 * @param groupBy A filter declaring how to group rows, formatted as an SQLGROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped.
 * @param having A filter declare which row groups to include in the cursor,if row grouping is being used, formatted as an SQL HAVING clause (excluding the HAVING itself). Passing null will cause all row groups to be included, and is required when row grouping is not being used.
 * @param orderBy How to order the rows, formatted as an SQL ORDER BY clause(excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
 * @param limit Limits the number of rows returned by the query,formatted as LIMIT clause. Passing null denotes no LIMIT clause.
 * @return the SQL query string
 */
public static String buildQueryString(boolean distinct,String tables,String[] columns,String where,String groupBy,String having,String orderBy,String limit){
  if (TextUtils.isEmpty(groupBy) && !TextUtils.isEmpty(having)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  StringBuilder query=new StringBuilder(120);
  query.append("String_Node_Str");
  if (distinct) {
    query.append("String_Node_Str");
  }
  if (columns != null && columns.length != 0) {
    appendColumns(query,columns);
  }
 else {
    query.append("String_Node_Str");
  }
  query.append("String_Node_Str");
  query.append(tables);
  appendClause(query,"String_Node_Str",where);
  appendClause(query,"String_Node_Str",groupBy);
  appendClause(query,"String_Node_Str",having);
  appendClause(query,"String_Node_Str",orderBy);
  appendClauseEscapeClause(query,"String_Node_Str",limit);
  return query.toString();
}

Fixed version (ground truth):
/** 
 * Build an SQL query string from the given clauses.
 * @param distinct true if you want each row to be unique, false otherwise.
 * @param tables The table names to compile the query against.
 * @param columns A list of which columns to return. Passing null willreturn all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
 * @param where A filter declaring which rows to return, formatted as an SQLWHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URL.
 * @param groupBy A filter declaring how to group rows, formatted as an SQLGROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped.
 * @param having A filter declare which row groups to include in the cursor,if row grouping is being used, formatted as an SQL HAVING clause (excluding the HAVING itself). Passing null will cause all row groups to be included, and is required when row grouping is not being used.
 * @param orderBy How to order the rows, formatted as an SQL ORDER BY clause(excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
 * @param limit Limits the number of rows returned by the query,formatted as LIMIT clause. Passing null denotes no LIMIT clause.
 * @return the SQL query string
 */
public static String buildQueryString(boolean distinct,String tables,String[] columns,String where,String groupBy,String having,String orderBy,String limit){
  if (TextUtils.isEmpty(groupBy) && !TextUtils.isEmpty(having)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!TextUtils.isEmpty(limit) && !sLimitPattern.matcher(limit).matches()) {
    throw new IllegalArgumentException("String_Node_Str" + limit);
  }
  StringBuilder query=new StringBuilder(120);
  query.append("String_Node_Str");
  if (distinct) {
    query.append("String_Node_Str");
  }
  if (columns != null && columns.length != 0) {
    appendColumns(query,columns);
  }
 else {
    query.append("String_Node_Str");
  }
  query.append("String_Node_Str");
  query.append(tables);
  appendClause(query,"String_Node_Str",where);
  appendClause(query,"String_Node_Str",groupBy);
  appendClause(query,"String_Node_Str",having);
  appendClause(query,"String_Node_Str",orderBy);
  appendClause(query,"String_Node_Str",limit);
  return query.toString();
}