示例#1
0
  public void testGetPrimaryKeysWithColumnFilters() throws Exception {

    // TODO (felipeal): I don't know if PK_TABLE is a standard JDBC name or if
    // it's HSQLDB specific. Anyway, now that HSQLDB's schema is set on property,
    // we cannot add it as prefix here....
    String tableName = "PK_TABLE";
    //        String tableName = DataSetUtils.getQualifiedName(
    //                _connection.getSchema(), "PK_TABLE");

    String[] expected = {"PK0", "PK2"};

    DefaultColumnFilter filter = new DefaultColumnFilter();
    filter.includeColumn("PK0");
    filter.includeColumn("PK2");

    IDatabaseConnection connection =
        new DatabaseConnection(_connection.getConnection(), _connection.getSchema());
    connection.getConfig().setProperty(DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER, filter);

    ITableMetaData metaData = connection.createDataSet().getTableMetaData(tableName);
    Column[] columns = metaData.getPrimaryKeys();

    assertEquals("column count", expected.length, columns.length);
    for (int i = 0; i < columns.length; i++) {
      assertEquals("column name", convertString(expected[i]), columns[i].getColumnName());
    }
  }
示例#2
0
  public void testGetPrimaryKeysAndQualifiedNamesEnabled() throws Exception {
    String tableName =
        new QualifiedTableName("PK_TABLE", _connection.getSchema()).getQualifiedName();
    String[] expected = {"PK0", "PK1", "PK2"};

    IDatabaseConnection connection =
        new DatabaseConnection(_connection.getConnection(), _connection.getSchema());
    connection.getConfig().setFeature(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true);

    ITableMetaData metaData = connection.createDataSet().getTableMetaData(tableName);
    Column[] columns = metaData.getPrimaryKeys();

    assertEquals("column count", expected.length, columns.length);
    for (int i = 0; i < columns.length; i++) {
      assertEquals("column name", convertString(expected[i]), columns[i].getColumnName());
    }
  }