Skip to content
Permalink
Browse files

0003847: Enhance fallback to handle duplicate key and foreign key errors

  • Loading branch information...
erilong committed Jan 8, 2019
1 parent 302f952 commit 8f69432fd82517063f685e06aa7f15d76228a322
@@ -24,9 +24,12 @@

import org.jumpmind.db.DbTestUtils;
import org.jumpmind.db.platform.ase.AseDatabasePlatform;
import org.jumpmind.db.platform.greenplum.GreenplumPlatform;
import org.jumpmind.db.platform.informix.InformixDatabasePlatform;
import org.jumpmind.db.platform.redshift.RedshiftDatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform;
import org.jumpmind.db.platform.sqlite.SqliteDatabasePlatform;
import org.jumpmind.db.platform.voltdb.VoltDbDatabasePlatform;
import org.jumpmind.symmetric.io.AbstractWriterTest;
import org.jumpmind.symmetric.io.data.CsvData;
import org.jumpmind.symmetric.io.data.DataEventType;
@@ -67,8 +70,11 @@ public static void setup() throws Exception {
// Ignore SQLite because it doesn't enforce FKs, and its unique constraint error message doesn't tell you the index name
// TODO: Sybase ASE has metadata problem in the DDL reader for exported keys
// TODO: Informix has metadata problem in the DDL reader for exported keys
// TODO: Untested on Volt, Greenplum, Redshift
shouldTest = !(platform instanceof SqliteDatabasePlatform || platform instanceof SqlAnywhereDatabasePlatform ||
platform instanceof AseDatabasePlatform || platform instanceof InformixDatabasePlatform);
platform instanceof AseDatabasePlatform || platform instanceof InformixDatabasePlatform ||
platform instanceof VoltDbDatabasePlatform || platform instanceof GreenplumPlatform ||
platform instanceof RedshiftDatabasePlatform);
}

@Test
@@ -1715,6 +1715,7 @@ public Trigger getTriggerFor(Table table, String triggerName) {
whereSql = whereSql.substring(0, whereSql.length() - delimiter.length());
}

Row foreignRow = new Row(foreignTable.getColumnCount());
if (foreignTable.getForeignKeyCount() > 0) {
DmlStatement selectSt = platform.createDmlStatement(DmlType.SELECT, foreignTable, null);
Object[] keys = whereRow.toArray(foreignTable.getPrimaryKeyColumnNames());
@@ -1724,13 +1725,13 @@ public Trigger getTriggerFor(Table table, String triggerName) {
"Unable to reload rows for missing foreign key data for table '{}', parent data not found. Using sql='{}' with keys '{}'",
foreignTable.getName(), selectSt.getSql(), keys);
} else {
Row foreignRow = new Row(foreignTable.getColumnCount());
foreignRow.putAll(values);
TableRow foreignTableRow = new TableRow(foreignTable, foreignRow, whereSql, referenceColumnName, fk.getName());
fkDepList.add(foreignTableRow);
log.debug("Add foreign table reference '{}' whereSql='{}'", foreignTable.getName(), whereSql);
}
}

TableRow foreignTableRow = new TableRow(foreignTable, foreignRow, whereSql, referenceColumnName, fk.getName());
fkDepList.add(foreignTableRow);
log.debug("Add foreign table reference '{}' whereSql='{}'", foreignTable.getName(), whereSql);
} else {
log.debug("The foreign table reference was null for {}", foreignTable.getName());
}

0 comments on commit 8f69432

Please sign in to comment.
You can’t perform that action at this time.