lowka commented on code in PR #6555:
URL: https://github.com/apache/ignite-3/pull/6555#discussion_r2354745015
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc2/JdbcResultSet.java:
##########
@@ -143,178 +146,299 @@ public String getString(int colIdx) throws SQLException
{
ensureNotClosed();
ensureHasCurrentRow();
- throw new UnsupportedOperationException();
+ Object value = getValue(colIdx);
+ if (value == null) {
+ return null;
+ }
+
+ if (value instanceof Temporal || value instanceof byte[] || value
instanceof UUID) {
+ throw new UnsupportedOperationException();
+ } else {
+ return String.valueOf(value);
+ }
}
/** {@inheritDoc} */
@Override
public String getString(String colLb) throws SQLException {
- ensureNotClosed();
- ensureHasCurrentRow();
+ int colIdx = findColumn(colLb);
- throw new UnsupportedOperationException();
+ return getString(colIdx);
}
/** {@inheritDoc} */
@Override
public boolean getBoolean(int colIdx) throws SQLException {
- ensureNotClosed();
- ensureHasCurrentRow();
+ Object val = getValue(colIdx);
- throw new UnsupportedOperationException();
+ if (val == null) {
+ return false;
+ }
+
+ if ("0".equals(val)) {
+ return false;
+ } else if ("1".equals(val)) {
+ return true;
+ } else if (val instanceof Boolean) {
+ return ((Boolean) val);
+ } else if (val instanceof Byte || val instanceof Short || val
instanceof Integer || val instanceof Long) {
+ long num = ((Number) val).longValue();
+
+ if (num == 0) {
+ return false;
+ } else if (num == 1) {
+ return true;
+ }
+ }
+
+ throw new SQLException("Cannot convert to boolean: " + val,
SqlStateCode.CONVERSION_FAILED);
}
/** {@inheritDoc} */
@Override
public boolean getBoolean(String colLb) throws SQLException {
- ensureNotClosed();
- ensureHasCurrentRow();
+ int colIdx = findColumn(colLb);
- throw new UnsupportedOperationException();
+ return getBoolean(colIdx);
}
/** {@inheritDoc} */
@Override
public byte getByte(int colIdx) throws SQLException {
- ensureNotClosed();
- ensureHasCurrentRow();
+ Object val = getValue(colIdx);
- throw new UnsupportedOperationException();
+ if (val == null) {
+ return 0;
+ }
+
+ if (val instanceof Number) {
+ return ((Number) val).byteValue();
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]