From 1fc757f1dd56f4f9f92c6a62376e7fcef1af22b7 Mon Sep 17 00:00:00 2001 From: yrizhkov Date: Sun, 17 Dec 2023 11:59:29 +0200 Subject: [PATCH] FMWK-291 Set wasNull flag in ResultSet --- .../jdbc/sql/AerospikeRecordResultSet.java | 16 ++++++++++++---- .../com/aerospike/jdbc/sql/BaseResultSet.java | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/aerospike/jdbc/sql/AerospikeRecordResultSet.java b/src/main/java/com/aerospike/jdbc/sql/AerospikeRecordResultSet.java index 990d1f2..a816d2e 100644 --- a/src/main/java/com/aerospike/jdbc/sql/AerospikeRecordResultSet.java +++ b/src/main/java/com/aerospike/jdbc/sql/AerospikeRecordResultSet.java @@ -43,19 +43,27 @@ protected boolean moveToNext() { @Override public Object getObject(String columnLabel) { logger.fine(() -> "getObject: " + columnLabel); + Object obj; if (columnLabel.equals(PRIMARY_KEY_COLUMN_NAME)) { - return getUserKey().map(Value::getObject).orElse(null); + obj = getUserKey().map(Value::getObject).orElse(null); + } else { + obj = getBin(columnLabel).orElse(null); } - return getBin(columnLabel).orElse(null); + wasNull = obj == null; + return obj; } @Override public String getString(String columnLabel) { logger.fine(() -> "getString: " + columnLabel); + String str; if (columnLabel.equals(PRIMARY_KEY_COLUMN_NAME)) { - return getUserKey().map(Value::toString).orElse(null); + str = getUserKey().map(Value::toString).orElse(null); + } else { + str = getBin(columnLabel).map(Object::toString).orElse(null); } - return getBin(columnLabel).map(Object::toString).orElse(null); + wasNull = str == null; + return str; } @Override diff --git a/src/main/java/com/aerospike/jdbc/sql/BaseResultSet.java b/src/main/java/com/aerospike/jdbc/sql/BaseResultSet.java index dd7e764..6627718 100644 --- a/src/main/java/com/aerospike/jdbc/sql/BaseResultSet.java +++ b/src/main/java/com/aerospike/jdbc/sql/BaseResultSet.java @@ -24,9 +24,10 @@ public abstract class BaseResultSet implements ResultSet, protected final List columns; private final Statement statement; private final ResultSetMetaData metadata; - protected volatile int index; + + protected int index; protected boolean afterLast; - private boolean wasNull; + protected boolean wasNull; private volatile boolean closed; protected BaseResultSet(Statement statement, String schema, String table, List columns) {