mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 20:44:23 +01:00
Fix isBeforeFirst to return false for empty ResultSet
This commit is contained in:
@@ -104,6 +104,11 @@ public final class TursoResultSet {
|
||||
return pastLastRow;
|
||||
}
|
||||
|
||||
/** Checks whether the result set is empty (has no rows). */
|
||||
public boolean isEmpty() {
|
||||
return isEmptyResultSet;
|
||||
}
|
||||
|
||||
/** Gets the current row number (0-based, 0 means before first row). */
|
||||
public int getRow() {
|
||||
return row;
|
||||
|
||||
@@ -413,6 +413,10 @@ public final class JDBC4ResultSet implements ResultSet, ResultSetMetaData {
|
||||
|
||||
@Override
|
||||
public boolean isBeforeFirst() throws SQLException {
|
||||
// Empty ResultSet should return false per JDBC spec
|
||||
if (resultSet.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return resultSet.isOpen() && resultSet.getRow() == 0 && !resultSet.isPastLastRow();
|
||||
}
|
||||
|
||||
|
||||
@@ -675,7 +675,8 @@ class JDBC4ResultSetTest {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM test_empty");
|
||||
|
||||
// Before calling next()
|
||||
assertTrue(resultSet.isBeforeFirst());
|
||||
// Empty ResultSet should return false for isBeforeFirst()
|
||||
assertFalse(resultSet.isBeforeFirst());
|
||||
assertFalse(resultSet.isAfterLast());
|
||||
|
||||
// After calling next() on empty ResultSet
|
||||
|
||||
Reference in New Issue
Block a user