Skip to content

Commit

Permalink
0002821: Fixed how dbcompare handles required columns with defaults t…
Browse files Browse the repository at this point in the history
…hat are not present on the source table
  • Loading branch information
evan-miller-jumpmind committed Aug 9, 2022
1 parent 4ccae60 commit 9ac56d4
Showing 1 changed file with 16 additions and 3 deletions.
Expand Up @@ -22,6 +22,8 @@

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jumpmind.db.model.Column;
Expand Down Expand Up @@ -85,11 +87,22 @@ public void writeInsert(DbCompareRow sourceCompareRow) {
}
try {
Table targetTable = tables.getTargetTable();
List<Column> targetColumns = new ArrayList<Column>();
List<Column> targetPkColumns = new ArrayList<Column>();
for (Column targetColumn : targetTable.getColumns()) {
if (tables.getColumnMapping().containsValue(targetColumn) || !targetColumn.isRequired()
|| targetColumn.getDefaultValue() == null) {
targetColumns.add(targetColumn);
if (targetColumn.isPrimaryKey()) {
targetPkColumns.add(targetColumn);
}
}
}
DmlStatement statement = targetEngine.getDatabasePlatform().createDmlStatement(DmlType.INSERT,
targetTable.getCatalog(), targetTable.getSchema(), targetTable.getName(),
targetTable.getPrimaryKeyColumns(), targetTable.getColumns(),
null, null);
Row row = new Row(targetTable.getColumnCount());
targetPkColumns.toArray(new Column[targetPkColumns.size()]),
targetColumns.toArray(new Column[targetColumns.size()]), null, null);
Row row = new Row(targetColumns.size());
for (Column sourceColumn : tables.getSourceTable().getColumns()) {
Column targetColumn = tables.getColumnMapping().get(sourceColumn);
if (targetColumn == null) {
Expand Down

0 comments on commit 9ac56d4

Please sign in to comment.