SOQL query doesn't retun value for COUNT()

Issue #89 resolved
Petr Švestka created an issue

Query:

select count() from Account

Output:

Executing:
===========================
select count() from Account
===========================
No rows returned.

Comments (10)

  1. Scott Wells repo owner

    I'll take a look in the next bug release. As a possible workaround, can you try "SELECT COUNT(Id) FROM Account" and see if you at least get results? Like I said, it's a workaround and not a fix until I can get you a proper fix.

  2. Petr Švestka reporter
    • changed status to open

    Seems the problem is still there :-)

    works:

    select count(id) from contact
    

    doesn't work:

    select count() from contact
    
  3. Scott Wells repo owner

    Petr, you won't see anything in the results table, but you will see "XXX rows would be returned" in the console view

    SELECT_COUNT.png

    Is this not what you're seeing?

    FYI, this is because a SELECT COUNT() SOQL query results an empty result set with a total result set size. Workbench does pretty much the same thing with this query.

    Let me know whether you're not seeing this behavior.

  4. Petr Švestka reporter

    This is very minor issue.

    The difference is per the attached screenshots. When no contacts are present, the empty set is presented differently. count.pngcount_id.png

  5. Scott Wells repo owner

    It may be minor, but it's still a bug. Those two should definitely return the same number of rows, the former as a message ("1 rows would be returned.") and the latter as a single value result set. I'll see if I can reproduce this in my environment as I'm working on the next update. Thanks for following up!

  6. Scott Wells repo owner

    Wait, I see now. They're returning the same information, just in different forms. One says "No rows returned" (probably should say "No rows would be returned") and the other says "1 rows returned" but the value for cnt is 0.

    Unfortunately without actually looking at the query to see if it's specifically a "SELECT COUNT()..." query, I can't tell whether there were no rows returned because there's really no result set or because it's only selecting COUNT(). If you ran this against an object with at least one row, it should show "XX rows would be returned".

    I'm going to resolve this for now. If you disagree with this explanation/assessment, please let me know.

  7. Log in to comment