function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
slaneslane 

Odd behavior with StandardSetController when zero records found

Hello all:

 

I've created a VisualForce page to display a paginated record set. I'm using a StandardSetController. Here's what's odd.

 

 

ApexPages.StandardSetController con = new ApexPages.StandardSetController(Database.getQueryLocator( someQuery ) );
System.debug( 'Record set size is ' + con.getResultSize() );

 

 What  have found to be so, I think, is that if someQuery returns NO records, the controller instead finds ALL records in the target table! So though con.getResultSize() should be zero (I would think) if the query returns no records, instead it's equal to the size of all rows in the target table!

 

So far I have to do a count() query before the fact in order to decide whether even to instantiate the controller.

 

It's hard to imagine such an obvious bug got through; it's also hard to imagine this is intended behavior.

 

Has anyone else seen this?