Skip to content

ResultSet.isBeforeFirst returns true if result set is empty #807

@gabrieleciech

Description

@gabrieleciech

I have recently upgraded my driver from jaybird 4.0.9 to 5.0.4 and I found a different behaviour for the ResultSet.isBeforeFirst method call when the result set is empty.

In version 4.0.9 the method correctly returns false if the query has no rows in the result set, instead in version 5.0.4 it returns true. In this way we no longer have the possibility of understanding whether a result set is empty or not.

It seems that this change was made while developing support for server-side scrolling in #693, by changing the initialization value of the variable isBeforeFirst in FbStatementFetcher

As a test query you can use:

SELECT 1 as myvar 
FROM rdb$database 
WHERE 1=0

and you get a different result executing the following code by changing the driver

var conn = DriverManager.getConnection(url, user, pass);
var stmt = conn.createStatement();
var query = "SELECT 1 as myvar FROM rdb$database WHERE 1=0"

ResultSet rs = stmt.executeQuery(strSQL);
if(!rs.isBeforeFirst()) {
    System.out.println("Result set is empty");
} else {
    System.out.println("Result set with records");
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions