Skip to content

Commit

Permalink
Now makes sure XML-defined FKs point to PKs. If not then assumes it s…
Browse files Browse the repository at this point in the history
…hould have been a PK (with a warning).
  • Loading branch information
johncurrier committed Feb 9, 2011
1 parent 1a241e1 commit 1143a7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/net/sourceforge/schemaspy/model/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ private void updateFromXmlMetadata(SchemaMeta schemaMeta) throws SQLException {
for (TableMeta tableMeta : schemaMeta.getTables()) {
Table table;

if (tableMeta.getRemoteSchema() != null) {
if (tableMeta.getRemoteCatalog() != null || tableMeta.getRemoteSchema() != null) {
table = remoteTables.get(getRemoteTableKey(tableMeta.getRemoteCatalog(), tableMeta.getRemoteSchema(), tableMeta.getName()));
} else {
table = combined.get(tableMeta.getName());
Expand Down
6 changes: 6 additions & 0 deletions src/net/sourceforge/schemaspy/model/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,12 @@ public String getName() {
return "Defined in XML";
}
};

// they forgot to say it was a primary key
if (!parentColumn.isPrimary()) {
logger.warning("Assuming " + parentColumn.getTable() + "." + parentColumn + " is a primary key due to being referenced by " + col.getTable() + "." + col);
parent.setPrimaryColumn(parentColumn);
}
}
} else {
logger.warning("Undefined table '" + fk.getTableName() + "' referenced by '" + getName() + '.' + col.getName() + "' in XML metadata");
Expand Down

0 comments on commit 1143a7f

Please sign in to comment.