getSize() on empty found set causing java exception

Calling getSize() on a foundset that is empty results in an index out of bounds exception on the array object.

I’ve attached a simple servoy solution that replicates the bug. Simply press the button to initiate an SQL query that purposefully returns no results. Calling getSize() on the resulting set causes a java exception.

I’ve only tried this under Servoy 2.2.4

Jim Olsen

GetSizeError.servoy (4.37 KB)

BTW, I realize that getSize() is intended to be used on a form based foundset, but it seems like an easy trap to fall into (like I did) that it let’s you call it, it is a logical name in Javascript, and it causes a Java exception that is not descriptive to the problem.

Jim Olsen

getDataSetByQuery returns a JSDataSet.
with

var count = searchResult.getMaxRowIndex();

you should not have problems.

Good example also in the “move sample” of getDataSetByQuery

Yes, but in fact it does let you call getSize() on it, and it does in fact cause a java exception. If it is not a valid call to make on a JSDataSet, it should not be an exported method. Since I deal with multiple types of foundsets at once, it is very easy to get confused and call the ‘wrong’ method. Given the loose typing in Javascript, it would avoid an easy trap to fall into to have a single call for both foundsets, or at least not have an exported method that just doesn’t work… Especially with a name like getSize()…

As I mentioned in my previous post, I realize the correct call to use, but it still seems like a bug to let you call a function that then throws a java exception.

Jim Olsen