Skip to content

Commit

Permalink
Fixes #3143 [CSV] Empty values for Date are not processed
Browse files Browse the repository at this point in the history
  • Loading branch information
ThuF committed Dec 22, 2023
1 parent d8f1919 commit 02631c8
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.csv.CSVRecord;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.dirigible.commons.api.helpers.DateTimeUtils;
Expand Down Expand Up @@ -352,11 +351,23 @@ protected void setValue(PreparedStatement preparedStatement, int i, String dataT
} else if (Types.CHAR == DataTypeUtils.getSqlTypeByDataType(dataType)) {
preparedStatement.setString(i, sanitize(value));
} else if (Types.DATE == DataTypeUtils.getSqlTypeByDataType(dataType)) {
preparedStatement.setDate(i, DateTimeUtils.parseDate(value));
if (value.equals("")) {
preparedStatement.setNull(i, DataTypeUtils.getSqlTypeByDataType(dataType));
} else {
preparedStatement.setDate(i, DateTimeUtils.parseDate(value));
}
} else if (Types.TIME == DataTypeUtils.getSqlTypeByDataType(dataType)) {
preparedStatement.setTime(i, DateTimeUtils.parseTime(value));
if (value.equals("")) {
preparedStatement.setNull(i, DataTypeUtils.getSqlTypeByDataType(dataType));
} else {
preparedStatement.setTime(i, DateTimeUtils.parseTime(value));
}
} else if (Types.TIMESTAMP == DataTypeUtils.getSqlTypeByDataType(dataType)) {
preparedStatement.setTimestamp(i, DateTimeUtils.parseDateTime(value));
if (value.equals("")) {
preparedStatement.setNull(i, DataTypeUtils.getSqlTypeByDataType(dataType));
} else {
preparedStatement.setTimestamp(i, DateTimeUtils.parseDateTime(value));
}
} else if (Types.INTEGER == DataTypeUtils.getSqlTypeByDataType(dataType)) {
value = numberize(value);
preparedStatement.setInt(i, Integer.parseInt(value));
Expand Down

0 comments on commit 02631c8

Please sign in to comment.