Program: 43851
Project: 43851
Buggy source:
/** 
 * Construct a SELECT statement suitable for use in a group of SELECT statements that will be joined through UNION operators in buildUnionQuery.
 * @param projectionIn A list of which columns to return. Passingnull will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
 * @param selection A filter declaring which rows to return,formatted as an SQL WHERE clause (excluding the WHERE itself).  Passing null will return all rows for the given URL.
 * @param selectionArgs You may include ?s in selection, whichwill be replaced by the values from selectionArgs, in order that they appear in the selection.  The values will be bound as Strings.
 * @param groupBy A filter declaring how to group rows, formattedas an SQL GROUP 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 inthe 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 sortOrder How to order the rows, formatted as an SQLORDER 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 resulting SQL SELECT statement
 */
public String buildQuery(String[] projectionIn,String selection,String[] selectionArgs,String groupBy,String having,String sortOrder,String limit){
  String[] projection=computeProjection(projectionIn);
  if (mWhereClause.length() > 0) {
    mWhereClause.append(')');
  }
  if (selection != null && selection.length() > 0) {
    if (mWhereClause.length() > 0) {
      mWhereClause.append("String_Node_Str");
    }
    mWhereClause.append('(');
    mWhereClause.append(selection);
    mWhereClause.append(')');
  }
  return buildQueryString(mDistinct,mTables,projection,mWhereClause.toString(),groupBy,having,sortOrder,limit);
}

Fixed version (ground truth):
/** 
 * Construct a SELECT statement suitable for use in a group of SELECT statements that will be joined through UNION operators in buildUnionQuery.
 * @param projectionIn A list of which columns to return. Passingnull will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
 * @param selection A filter declaring which rows to return,formatted as an SQL WHERE clause (excluding the WHERE itself).  Passing null will return all rows for the given URL.
 * @param selectionArgs You may include ?s in selection, whichwill be replaced by the values from selectionArgs, in order that they appear in the selection.  The values will be bound as Strings.
 * @param groupBy A filter declaring how to group rows, formattedas an SQL GROUP 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 inthe 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 sortOrder How to order the rows, formatted as an SQLORDER 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 resulting SQL SELECT statement
 */
public String buildQuery(String[] projectionIn,String selection,String[] selectionArgs,String groupBy,String having,String sortOrder,String limit){
  String[] projection=computeProjection(projectionIn);
  StringBuilder where=new StringBuilder();
  if (mWhereClause.length() > 0) {
    where.append(mWhereClause.toString());
    where.append(')');
  }
  if (selection != null && selection.length() > 0) {
    if (mWhereClause.length() > 0) {
      where.append("String_Node_Str");
    }
    where.append('(');
    where.append(selection);
    where.append(')');
  }
  return buildQueryString(mDistinct,mTables,projection,where.toString(),groupBy,having,sortOrder,limit);
}