Skip to content

Commit

Permalink
Now treats DB2 MQTs as views
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Apr 30, 2010
1 parent e3fe369 commit fbda39c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions dist/releaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ <h3><a href='http://schemaspy.sourceforge.net'>SchemaSpy</a> Release Notes</h3>
the scope of SchemaSpy, so plug in your own if desired.
Use -dp to make the specified class visible to SchemaSpy's class loader.
</li>
<li>Now treats DB2 Materialized Query Tables (MQTs) as views per
<a href='https://sourceforge.net/projects/schemaspy/forums/forum/462849/topic/3586068'>
Jonas Söderström's suggestion</a>.
</li>
</ul>
</li>

Expand Down
3 changes: 3 additions & 0 deletions src/net/sourceforge/schemaspy/dbTypes/db2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ selectIndexIdsSql=select iid index_id, indname index_name, tabname table_name fr
# this says which schemas to include in our evaluation of "all schemas"
# basically .* (at the end) matches anything and the rest of it says "except schemas starting with SYS"
schemaSpec=(?!^SYS.*$).*

# treat DB2's MQTs as views
viewTypes=VIEW, MATERIALIZED QUERY TABLE
25 changes: 23 additions & 2 deletions src/net/sourceforge/schemaspy/model/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void initTables(final DatabaseMetaData metadata, final Properties proper
if (verbose)
System.out.println();

String[] types = {"TABLE"};
String[] types = getTypes("tableTypes", "TABLE", properties);
NameValidator validator = new NameValidator("table", include, exclude, verbose, types);
List<BasicTableMeta> entries = getBasicTableMeta(metadata, true, properties, types);

Expand Down Expand Up @@ -263,7 +263,7 @@ private void initViews(DatabaseMetaData metadata, Properties properties,
if (verbose)
System.out.println();

String[] types = {"VIEW"};
String[] types = getTypes("viewTypes", "VIEW", properties);
NameValidator validator = new NameValidator("view", includeTables, excludeTables, verbose, types);

for (BasicTableMeta entry : getBasicTableMeta(metadata, false, properties, types)) {
Expand Down Expand Up @@ -391,6 +391,27 @@ private List<BasicTableMeta> getBasicTableMeta(DatabaseMetaData metadata,
return basics;
}

/**
* Return a database-specific array of types from the .properties file
* with the specified property name.
*
* @param propName
* @param defaultValue
* @param props
* @return
*/
private String[] getTypes(String propName, String defaultValue, Properties props) {
String value = props.getProperty(propName, defaultValue);
List<String> types = new ArrayList<String>();
for (String type : value.split(",")) {
type = type.trim();
if (type.length() > 0)
types.add(type);
}

return types.toArray(new String[types.size()]);
}

/**
* Some databases don't play nice with their metadata.
* E.g. Oracle doesn't have a REMARKS column at all.
Expand Down

0 comments on commit fbda39c

Please sign in to comment.