Skip to content

Commit

Permalink
Case-insensitive determination of implied foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Sep 15, 2008
1 parent 6ed97b5 commit 39aa39f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/net/sourceforge/schemaspy/DbAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public static List<ImpliedForeignKeyConstraint> getImpliedConstraints(Collection
List<TableColumn> columnsWithoutParents = new ArrayList<TableColumn>();
Map<TableColumn, Table> allPrimaries = new TreeMap<TableColumn, Table>(new Comparator<TableColumn>() {
public int compare(TableColumn column1, TableColumn column2) {
int rc = column1.getName().compareTo(column2.getName());
int rc = column1.getName().compareToIgnoreCase(column2.getName());
if (rc == 0)
rc = column1.getType().compareTo(column2.getType());
rc = column1.getType().compareToIgnoreCase(column2.getType());
if (rc == 0)
rc = column1.getLength() - column2.getLength();
return rc;
Expand All @@ -56,7 +56,7 @@ public int compare(TableColumn column1, TableColumn column2) {
}

// if more than half of the tables have the same primary key then
// it's most likey a database where primary key names aren't unique
// it's most likely a database where primary key names aren't unique
// (e.g. they all have a primary key named 'ID')
if (duplicatePrimaries > allPrimaries.size()) // bizarre logic, but it does approximately what we need
return new ArrayList<ImpliedForeignKeyConstraint>();
Expand Down Expand Up @@ -200,7 +200,7 @@ public static List<Table> getTablesWithOneColumn(Collection<Table> tables) {
public static List<Table> sortTablesByName(List<Table> tables) {
Collections.sort(tables, new Comparator<Table>() {
public int compare(Table table1, Table table2) {
return table1.getName().compareTo(table2.getName());
return table1.getName().compareToIgnoreCase(table2.getName());
}
});

Expand All @@ -210,9 +210,9 @@ public int compare(Table table1, Table table2) {
public static List<TableColumn> sortColumnsByTable(List<TableColumn> columns) {
Collections.sort(columns, new Comparator<TableColumn>() {
public int compare(TableColumn column1, TableColumn column2) {
int rc = column1.getTable().getName().compareTo(column2.getTable().getName());
int rc = column1.getTable().getName().compareToIgnoreCase(column2.getTable().getName());
if (rc == 0)
rc = column1.getName().compareTo(column2.getName());
rc = column1.getName().compareToIgnoreCase(column2.getName());
return rc;
}
});
Expand Down

0 comments on commit 39aa39f

Please sign in to comment.