Skip to content

Commit 17adc7f

Browse files
author
Olha Virolainen
authored
Merge pull request #8 from elasticio/fixUpsertNull
Add check on JsonValue.NULL
2 parents edf1f7d + 7801bb9 commit 17adc7f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/io/elastic/jdbc/Utils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,31 +102,31 @@ public static void setStatementParam(PreparedStatement statement, int paramNumbe
102102
JsonObject body) throws SQLException {
103103
try {
104104
if (isNumeric(colName)) {
105-
if (body.get(colName) != null) {
105+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
106106
statement.setBigDecimal(paramNumber, body.getJsonNumber(colName).bigDecimalValue());
107107
} else {
108108
statement.setBigDecimal(paramNumber, null);
109109
}
110110
} else if (isTimestamp(colName)) {
111-
if (body.get(colName) != null) {
111+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
112112
statement.setTimestamp(paramNumber, Timestamp.valueOf(body.getString(colName)));
113113
} else {
114114
statement.setTimestamp(paramNumber, null);
115115
}
116116
} else if (isDate(colName)) {
117-
if (body.get(colName) != null) {
117+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
118118
statement.setDate(paramNumber, Date.valueOf(body.getString(colName)));
119119
} else {
120120
statement.setDate(paramNumber, null);
121121
}
122122
} else if (isBoolean(colName)) {
123-
if (body.get(colName) != null) {
123+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
124124
statement.setBoolean(paramNumber, body.getBoolean(colName));
125125
} else {
126126
statement.setBoolean(paramNumber, false);
127127
}
128128
} else {
129-
if (body.get(colName) != null) {
129+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
130130
statement.setString(paramNumber, body.getString(colName));
131131
} else {
132132
statement.setNull(paramNumber, Types.VARCHAR);

0 commit comments

Comments
 (0)