From 1c96640ad8d239bae6964e94489ea9d4b37472c4 Mon Sep 17 00:00:00 2001 From: Luca Rota Date: Thu, 1 Aug 2024 17:35:05 +0200 Subject: [PATCH] Fix String to int conversion --- .../salesforce/resultset/CachedResultSet.java | 20 +++++++++++-------- .../statement/ForcePreparedStatement.java | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/ascendix/jdbc/salesforce/resultset/CachedResultSet.java b/src/main/java/com/ascendix/jdbc/salesforce/resultset/CachedResultSet.java index dfac92b..4ec7898 100644 --- a/src/main/java/com/ascendix/jdbc/salesforce/resultset/CachedResultSet.java +++ b/src/main/java/com/ascendix/jdbc/salesforce/resultset/CachedResultSet.java @@ -388,27 +388,31 @@ public long getLong(int columnIndex) { } public int getInt(String columnName) { - return new ColumnValueParser<>(Integer::parseInt, Integer.class) + return new ColumnValueParser<>(Double::parseDouble, Double.class) .parse(columnName) - .orElse(0); + .orElse(0d) + .intValue(); } public int getInt(int columnIndex) { - return new ColumnValueParser<>(Integer::parseInt, Integer.class) + return new ColumnValueParser<>(Double::parseDouble, Double.class) .parse(columnIndex) - .orElse(0); + .orElse(0d) + .intValue(); } public short getShort(String columnName) { - return new ColumnValueParser<>(Short::parseShort, Short.class) + return new ColumnValueParser<>(Double::parseDouble, Double.class) .parse(columnName) - .orElse((short) 0); + .orElse(0d) + .shortValue(); } public short getShort(int columnIndex) { - return new ColumnValueParser<>(Short::parseShort, Short.class) + return new ColumnValueParser<>(Double::parseDouble, Double.class) .parse(columnIndex) - .orElse((short) 0); + .orElse(0d) + .shortValue(); } public InputStream getBinaryStream(int columnIndex) { diff --git a/src/main/java/com/ascendix/jdbc/salesforce/statement/ForcePreparedStatement.java b/src/main/java/com/ascendix/jdbc/salesforce/statement/ForcePreparedStatement.java index b99c936..97a93c5 100644 --- a/src/main/java/com/ascendix/jdbc/salesforce/statement/ForcePreparedStatement.java +++ b/src/main/java/com/ascendix/jdbc/salesforce/statement/ForcePreparedStatement.java @@ -258,7 +258,7 @@ private TypeInfo findColumnType(String name) { if (name == null) { return TypeInfo.OTHER_TYPE_INFO; } - if (name.indexOf(".") != 1) { + if (name.contains(".")) { /* Remove relation reference */ name = name.substring(name.indexOf(".") + 1); }