Skip to content

Commit

Permalink
Hack to remove erroneous table comments put in by MySQL's InnoDB engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Aug 8, 2008
1 parent 9b539fc commit 7b2f868
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/net/sourceforge/schemaspy/model/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,23 @@ public String getComments() {
}

public void setComments(String comments) {
this.comments = (comments == null || comments.trim().length() == 0) ? null : comments.trim();
String cmts = (comments == null || comments.trim().length() == 0) ? null : comments.trim();

// MySQL's InnoDB engine does some insane crap of storing erroneous details in
// with table comments. Here I attempt to strip the "crap" out without impacting
// other databases. Ideally this should happen in selectColumnCommentsSql (and
// therefore isolate it to MySQL), but it's a bit too complex to do cleanly.
if (cmts != null) {
int crapIndex = cmts.indexOf("; InnoDB free: ");
if (crapIndex == -1)
crapIndex = cmts.startsWith("InnoDB free: ") ? 0 : -1;
if (crapIndex != -1) {
cmts = cmts.substring(0, crapIndex).trim();
cmts = cmts.length() == 0 ? null : cmts;
}
}

this.comments = cmts;
}

public TableColumn getColumn(String columnName) {
Expand Down

0 comments on commit 7b2f868

Please sign in to comment.