Skip to content

Commit

Permalink
0001448: Provide global parameter to specify that BSH database writer…
Browse files Browse the repository at this point in the history
… filters will handle missing tables
  • Loading branch information
mhanes committed Oct 21, 2013
1 parent 0e7cb61 commit ffba45a
Showing 1 changed file with 36 additions and 25 deletions.
Expand Up @@ -38,6 +38,7 @@
import org.jumpmind.db.platform.DatabaseMetaDataWrapper;
import org.jumpmind.db.platform.DdlException;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.SqlException;

/*
* Reads a database model from a Microsoft Sql Server database.
Expand All @@ -63,35 +64,45 @@ public MsSqlDdlReader(IDatabasePlatform platform) {
@Override
protected Table readTable(Connection connection, DatabaseMetaDataWrapper metaData,
Map<String, Object> values) throws SQLException {
String tableName = (String) values.get("TABLE_NAME");

for (int idx = 0; idx < KNOWN_SYSTEM_TABLES.length; idx++) {
if (KNOWN_SYSTEM_TABLES[idx].equals(tableName)) {
return null;

try {
String tableName = (String) values.get("TABLE_NAME");

for (int idx = 0; idx < KNOWN_SYSTEM_TABLES.length; idx++) {
if (KNOWN_SYSTEM_TABLES[idx].equals(tableName)) {
return null;
}
}
}

Table table = super.readTable(connection, metaData, values);

if (table != null) {
// Sql Server does not return the auto-increment status via the
// database metadata
determineAutoIncrementFromResultSetMetaData(connection, table, table.getColumns());

// TODO: Replace this manual filtering using named pks once they are
// available
// This is then probably of interest to every platform
for (int idx = 0; idx < table.getIndexCount();) {
IIndex index = table.getIndex(idx);

if (index.isUnique() && existsPKWithName(metaData, table, index.getName())) {
table.removeIndex(idx);
} else {
idx++;

Table table = super.readTable(connection, metaData, values);

if (table != null) {
// Sql Server does not return the auto-increment status via the
// database metadata
determineAutoIncrementFromResultSetMetaData(connection, table, table.getColumns());

// TODO: Replace this manual filtering using named pks once they are
// available
// This is then probably of interest to every platform
for (int idx = 0; idx < table.getIndexCount();) {
IIndex index = table.getIndex(idx);

if (index.isUnique() && existsPKWithName(metaData, table, index.getName())) {
table.removeIndex(idx);
} else {
idx++;
}
}
}
return table;
} catch (SqlException e) {
if (e.getMessage().contains("does not exist")) {
return null;
} else {
throw e;
}
}
return table;

}

@Override
Expand Down

0 comments on commit ffba45a

Please sign in to comment.