Fixed #23875 -- cleaned up query.get_count()

The query.get_count() can be significantly cleared up due to expressions API changes.
I believe before this case was hacked around in upper layers, so that as_sql() was never called for the limit 0 case. There might be other cases that didn't work before but now work (for example "EmptyResultSet" from WhereNode).