Skip to content

Commit

Permalink
0003156: Validate the number of table columns match the number of data
Browse files Browse the repository at this point in the history
elements before attempting to load data
  • Loading branch information
chenson42 committed Jun 13, 2017
1 parent ed3a1c2 commit b955d35
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -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:
Expand Down

0 comments on commit b955d35

Please sign in to comment.