fix(iris): display %Boolean columns as stored 1/0 values

This commit is contained in:
zipg authored and GitHub committed 2026-09-25 23:52:18 +08:00
1 parent a71e4534ae
commit 070e09c615
4 files changed
+100

No files matched your search

@@ -78,6 +78,15 @@ public final class IrisAgent extends ConfiguredJdbcAgent {
Object value = rs.getBigDecimal(index);
return rs.wasNull() ? null : value;
});
case Types.BIT:
case Types.BOOLEAN:
// IRIS has no boolean type: %Boolean is stored as 1/0 and only
// the JDBC driver turns it into a Java boolean, which would
// surface as true/false in the grid. Report the stored 1/0.
return unchecked(() -> {
int value = rs.getInt(index);
return rs.wasNull() ? null : value;
});
case Types.OTHER:
return unchecked(() -> JdbcExecutor.normalizeResultValue(rs.getObject(index)));
default:
@@ -147,6 +147,47 @@ class IrisAgentTest {
assertEquals(Collections.singletonList("getObject"), calls);
}
@Test
void readsBitColumnsAsStoredNumbers() {
for (int sqlType : new int[] {Types.BIT, Types.BOOLEAN}) {
List<String> calls = new ArrayList<>();
ResultSet resultSet = proxy(ResultSet.class, (method, args) -> {
if ("getInt".equals(method.getName())) {
calls.add("getInt");
return 1;
}
if (method.getName().startsWith("get")) {
calls.add(method.getName());
throw new AssertionError("IRIS %Boolean must not be read as a Java boolean");
}
if ("wasNull".equals(method.getName())) {
return false;
}
return defaultValue(method.getReturnType());
});
Object value = new IrisAgent().resultValue(resultSet, 1, sqlType);
assertEquals(1, value);
assertEquals(Collections.singletonList("getInt"), calls);
}
}
@Test
void preservesNullForBitColumns() {
ResultSet resultSet = proxy(ResultSet.class, (method, args) -> {
if ("getInt".equals(method.getName())) {
return 0;
}
if ("wasNull".equals(method.getName())) {
return true;
}
return defaultValue(method.getReturnType());
});
assertNull(new IrisAgent().resultValue(resultSet, 1, Types.BIT));
}
@Test
void readsColumnsAndUsesInlinePrimaryKey() {
List<String> calls = new ArrayList<>();