Skip to content

Commit

Permalink
0005238: Bulk loaders should report missing table
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Mar 14, 2022
1 parent c53b2a9 commit b1207f3
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -21,9 +21,12 @@
package org.jumpmind.symmetric.io;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.SqlException;
import org.jumpmind.db.sql.TableNotFoundException;
import org.jumpmind.symmetric.common.ContextConstants;
import org.jumpmind.symmetric.io.data.Batch;
import org.jumpmind.symmetric.io.data.CsvData;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.jumpmind.symmetric.io.data.writer.DynamicDefaultDatabaseWriter;
import org.slf4j.Logger;
Expand Down Expand Up @@ -56,6 +59,20 @@ public void start(Batch batch) {
}

public final void write(CsvData data) {
if (data.requiresTable() && data.getDataEventType() != DataEventType.SQL) {
if (sourceTable == null) {
throw new SqlException("The target table was not specified");
} else if (targetTable == null) {
String qualifiedName = sourceTable.getFullyQualifiedTableName();
if (writerSettings.isIgnoreMissingTables() || batch.getBatchId() == IoConstants.IGNORE_TABLES_BATCH) {
if (missingTables.add(qualifiedName)) {
log.info("Did not find the {} table in the target database", qualifiedName);
}
} else {
throw new TableNotFoundException(String.format("Could not find the target table '%s'", qualifiedName));
}
}
}
if (isFallBackToDefault()) {
writeDefault(data);
} else {
Expand Down

0 comments on commit b1207f3

Please sign in to comment.