Skip to content

Commit

Permalink
0002103 - Remove auto increment attribute as part of table creation f…
Browse files Browse the repository at this point in the history
…or identity columns that are not part of the PK for databases that do not support it.
  • Loading branch information
jhicks committed Dec 16, 2014
1 parent 377f247 commit bbd0634
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Expand Up @@ -830,5 +830,19 @@ public Database readDatabaseFromXml(InputStream is, boolean alterCaseToMatchData
public boolean canColumnBeUsedInWhereClause(Column column) {
return true;
}

@Override
public void makePlatformSpecific(Database database) {
Table[] tables = database.getTables();
for (Table table : tables) {
for (Column autoIncrementColumn : table.getAutoIncrementColumns()) {
if (!autoIncrementColumn.isPrimaryKey() && !getDatabaseInfo().isNonPKIdentityColumnsSupported()) {
log.info("Removing auto increment from table " + table.getName() + " for column " + autoIncrementColumn.getName() +
" since it was not part of primary key and not supported on this database based on nonPKIdentityColumnsSupported.");
autoIncrementColumn.setAutoIncrement(false);
}
}
}
}

}
Expand Up @@ -177,4 +177,6 @@ public Object[] getObjectValues(BinaryEncoding encoding, String[] values,

public boolean canColumnBeUsedInWhereClause(Column column);

public void makePlatformSpecific(Database database);

}
Expand Up @@ -501,7 +501,9 @@ protected boolean create(CsvData data) {
if (writerSettings.isCreateTableAlterCaseToMatchDatabaseDefault()) {
platform.alterCaseToMatchDatabaseDefaultCase(db);
}


platform.makePlatformSpecific(db);

if (writerSettings.isAlterTable()) {
platform.alterDatabase(db, !writerSettings.isCreateTableFailOnError());
} else {
Expand Down

0 comments on commit bbd0634

Please sign in to comment.