I accidentally discovered this bug today while working with the MetaModel codebase.
It seems that when doing an "approximate COUNT" query on a CSV file we don't check if there are any WHERE items present in the query also. I added that as a check to return null when there are where items in the query (indicating that the count query cannot be handled in a optimized fashion - which will in turn cause a count to be made by actually counting all records). The patch is available here: https://gist.github.com/kaspersorensen/6079811 Regards, Kasper
