Skip to content

Commit

Permalink
Added an optional short_column_type to selectColumnTypesSql to simpli…
Browse files Browse the repository at this point in the history
…fy the generated ER diagrams. Otherwise they could become extremely large.
  • Loading branch information
johncurrier committed Feb 10, 2011
1 parent fb2a50d commit 3b9e48d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
3 changes: 2 additions & 1 deletion dist/dbtypes.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ <h4>Custom SQL</h4>
<tr>
<td>selectColumnTypesSql</td>
<td>table_name, column_name, column_type</td>
<td>&nbsp;</td>
<td>short_column_type</td>
<td>Details of unusual column types such as ENUMs.
The short version is used within ER diagrams to help make them more readable.
</td>
<td>Database</td>
</tr>
Expand Down
13 changes: 10 additions & 3 deletions dist/releaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ <h3><a href='http://schemaspy.sourceforge.net'>SchemaSpy</a> Release Notes</h3>

<li class='release'>x.x.x - xx/xx/xxxx - Subversion revision 596
<ul>
<li>Changed default from -lq (low quality) to -hq (high quality) after
seeing how the low quality diagrams look on various systems.<br>
<li>Added an optional <code>short_column_type</code> to
<code>selectColumnTypesSql</code> to simplify the generated ER diagrams.
Otherwise they could become extremely large.
rev 624
</li>
<li>Changed default from <code>-lq</code> (low quality) to <code>-hq</code>
(high quality) after seeing how the low quality diagrams look on
various systems.<br>
rev 623
</li>
<li>Implemented <a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1598563&group_id=137197&atid=737990">
Expand All @@ -25,7 +31,8 @@ <h3><a href='http://schemaspy.sourceforge.net'>SchemaSpy</a> Release Notes</h3>
</li>
<li>Low quality rendering was always being used when multiple schemas
were being analyzed.
Now honors -hq or -lq from command-line in for multiples.<br>
Now honors <code>-hq</code> or <code>-lq</code> from command-line for
multiples.<br>
rev 620
</li>
<li>Now makes sure XML-defined FKs point to PKs.
Expand Down
7 changes: 4 additions & 3 deletions src/net/sourceforge/schemaspy/dbTypes/mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ selectViewsSql=select table_schema as view_catalog, null as view_schema, table_n
# this is only used for remote tables since row_count was returned in selectTablesSql
selectRowCountSql=select table_rows row_count from information_schema.tables where table_name=:table

# return table_name, column_name, column_type for a specific :schema
# for all column types that have special formatting
selectColumnTypesSql=select table_name, column_name, column_type from information_schema.columns where table_schema=:schema and (column_type like 'enum(%' or column_type like 'set(%')
# return table_name, column_name, column_type, short_column_type for a specific :schema
# for all column types that have special formatting.
# short_column_type is optional and is used in the ER diagrams to keep them from becoming bloated
selectColumnTypesSql=select table_name, column_name, replace(column_type,"','","', '") as column_type, left(column_type, locate("(", column_type)-1) as short_column_type from information_schema.columns where table_schema=:schema and (column_type like 'enum(%' or column_type like 'set(%')
1 change: 1 addition & 0 deletions src/net/sourceforge/schemaspy/model/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ private void initColumnTypes(Properties properties) throws SQLException {
TableColumn column = table.getColumn(columnName);
if (column != null) {
column.setType(rs.getString("column_type"));
column.setShortType(getOptionalString(rs, "short_column_type"));
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/net/sourceforge/schemaspy/model/TableColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class TableColumn {
private final String name;
private final Object id;
private String type;
private String shortType;
private final int length;
private final int decimalDigits;
private final String detailedSize;
Expand Down Expand Up @@ -173,6 +174,24 @@ public void setType(String type) {
this.type = type;
}

/**
* Abbreviated form of {@link #getType()}
*
* @return
*/
public String getShortType() {
return shortType == null ? type : shortType;
}

/**
* Abbreviated form of {@link #setType(String)}
*
* @param shortType
*/
public void setShortType(String shortType) {
this.shortType = shortType;
}

/**
* Length of the column.
* See {@link DatabaseMetaData#getColumns(String, String, String, String)}'s <code>BUFFER_LENGTH</code>,
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/schemaspy/view/DotNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ else if (indexColumns.contains(column))
buf.append("<TD PORT=\"");
buf.append(column.getName());
buf.append(".type\" ALIGN=\"LEFT\">");
buf.append(column.getType().toLowerCase());
buf.append(column.getShortType().toLowerCase());
buf.append("[");
buf.append(column.getDetailedSize());
buf.append("]</TD>");
Expand Down

0 comments on commit 3b9e48d

Please sign in to comment.