public TableColumnComparator(ComparisonConfig config) {
super(config);
}
public void compareObjects(DBColumn col1, DBColumn col2, CompositeStructuralChange<?> tableChange) {
ColumnChange columnChange = new ColumnChange(col1);
// check column type, size and fractionDigits
DBDataType newType = col2.getType();
Integer newSize = col2.getSize();
Integer newFractionDigits = col2.getFractionDigits();
if (!col1.getType().equals(newType)
|| !NullSafeComparator.equals(col1.getSize(), newSize)
|| !NullSafeComparator.equals(col1.getFractionDigits(), newFractionDigits))
columnChange.addSubChange(new ColumnTypeChange(col1, newType, newSize, newFractionDigits));
// check column default
if (!NullSafeComparator.equals(col1.getDefaultValue(), col2.getDefaultValue()))
columnChange.addSubChange(new DefaultValueChange(col1, col2.getDefaultValue()));
// check column nullability
if (col1.isNullable() && !col2.isNullable())
columnChange.addSubChange(new NotNullConstraintCreation(col2.getNotNullConstraint()));
if (!col1.isNullable() && col2.isNullable())
columnChange.addSubChange(new ConstraintDeletion<DBNotNullConstraint>(col1.getNotNullConstraint()));
// if there were changes, add them to the parent tableChange
if (columnChange.getSubChanges().size() > 0)
tableChange.addSubChange(columnChange);
}