Skip to content

Commit

Permalink
0005320: Use unique index for PK column names when table is missing PK
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Jun 1, 2022
1 parent 3512c3f commit a7c54c8
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -710,9 +710,19 @@ public Map<String, String> parseQualifiedTableName(String tableName) {

public Table makeAllColumnsPrimaryKeys(Table table) {
Table result = table.copy();
for (Column column : result.getColumns()) {
if (!isLob(column.getMappedTypeCode())) {
column.setPrimaryKey(true);
IIndex[] indices = result.getUniqueIndices();
if (indices != null && indices.length > 0) {
for (IndexColumn indexColumn : indices[0].getColumns()) {
Column column = result.getColumnWithName(indexColumn.getName());
if (column != null) {
column.setPrimaryKey(true);
}
}
} else {
for (Column column : result.getColumns()) {
if (!isLob(column.getMappedTypeCode())) {
column.setPrimaryKey(true);
}
}
}
return result;
Expand Down

0 comments on commit a7c54c8

Please sign in to comment.