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

The query.get_count() can be significantly cleared up due to expressions API changes.
I'm not clear about this addition. Is it related in some way to the count change? Is it fixing a previously-latent bug that the count change happened to expose?