From b955d3516b93235f7049cba84973d70b8f8fd8b1 Mon Sep 17 00:00:00 2001 From: Chris Henson Date: Tue, 13 Jun 2017 13:21:15 -0400 Subject: [PATCH] 0003156: Validate the number of table columns match the number of data elements before attempting to load data --- .../symmetric/io/data/writer/AbstractDatabaseWriter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/AbstractDatabaseWriter.java b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/AbstractDatabaseWriter.java index 95636449f8..a3ff346b47 100644 --- a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/AbstractDatabaseWriter.java +++ b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/AbstractDatabaseWriter.java @@ -156,13 +156,13 @@ public void write(CsvData data) { switch (data.getDataEventType()) { case UPDATE: case INSERT: - if (targetTable.getColumnCount() != data.getParsedData(CsvData.ROW_DATA).length) { - throw new ParseException(String.format("The (%s) table's column count (%d) does not match the data's column count (%d)", targetTable.getName(), targetTable.getColumnCount(), data.getParsedData(CsvData.ROW_DATA).length)); + if (sourceTable.getColumnCount() != data.getParsedData(CsvData.ROW_DATA).length) { + throw new ParseException(String.format("The (%s) table's column count (%d) does not match the data's column count (%d)", sourceTable.getName(), sourceTable.getColumnCount(), data.getParsedData(CsvData.ROW_DATA).length)); } break; case DELETE: - if (targetTable.getPrimaryKeyColumnCount() != data.getParsedData(CsvData.PK_DATA).length) { - throw new ParseException(String.format("The (%s) table's pk column count (%d) does not match the data's pk column count (%d)", targetTable.getName(), targetTable.getPrimaryKeyColumnCount(), data.getParsedData(CsvData.PK_DATA).length)); + if (sourceTable.getPrimaryKeyColumnCount() != data.getParsedData(CsvData.PK_DATA).length) { + throw new ParseException(String.format("The (%s) table's pk column count (%d) does not match the data's pk column count (%d)", sourceTable.getName(), sourceTable.getPrimaryKeyColumnCount(), data.getParsedData(CsvData.PK_DATA).length)); } break; default: