result = new TableDiffResult();
// first check for all columns of the reference table
final Iterator<Column> refIter = referenceTable.getColumnIterator();
if (refIter != null) {
while (refIter.hasNext()) {
final Column col = refIter.next();
Logger.debug("[TableDiffer.diffTables] querying table for '%s'", col.getName());
final Column diff = diffTable.getColumnByName(col.getName(), colNameIgnoreCase);
Logger.debug("[TableDiffer.diffTables] got: '%s'", diff);
if (diff == null) {
Logger.debug("missing col: '%s'", col.getName());
result.addRemovedColumn(col);
} else if (!col.equals(diff, colNameIgnoreCase)) {
Logger.debug("modified col: '%s'", col.getName());
result.putModifiedColumns(col, diff);
}
}
}
// now check for columns which were added to the second table
final Iterator<Column> diffIter = diffTable.getColumnIterator();
if (diffIter != null) {
while (diffIter.hasNext()) {
final Column col = diffIter.next();
final Column ref = referenceTable.getColumnByName(col.getName(), colNameIgnoreCase);
if (ref == null) {
Logger.debug("added col: '%s'", col.getName());
result.addAddedColumn(col);
}
}