Ejemplo n.º 1
0
  private static SQLResult getFilteredRowsFromSQL(
      Connection conn,
      String schema,
      String table,
      int[] columns,
      NestedColumnFilters filters,
      Map<Integer, DataEntity> entities)
      throws SQLException {
    String[] quotedFields = new String[columns.length];
    for (int i = 0; i < columns.length; i++)
      quotedFields[i] =
          SQLUtils.quoteSymbol(
              conn, entities.get(columns[i]).privateMetadata.get(PrivateMetadata.SQLCOLUMN));

    WhereClause<Object> where =
        WhereClause.fromFilters(conn, convertColumnIdsToFieldNames(filters, entities));

    String query =
        String.format(
            "SELECT %s FROM %s %s",
            Strings.join(",", quotedFields),
            SQLUtils.quoteSchemaTable(conn, schema, table),
            where.clause);

    return SQLUtils.getResultFromQuery(conn, query, where.params.toArray(), false);
  }