/
Count SQL generation fails on DISTINCT in subquery

Count SQL generation fails on DISTINCT in subquery

Imported from: http://groups.google.com/group/in-portal-bugs/browse_thread/thread/4635504373ca3d86#

There's bug with kDBList::getCountSQL method, which generates SQL for counting list totals. It checks if there's DISTINCT in SQL and, if it's there, tries to replace it for COUNT(DISTINCT ...) construction instead of simple COUNT(*). Problem is that it checks for distinct in ANY place of query, but replaces it in beginning, so, if there's DISTINCT in subquery, it won't replace anything. So, count SQL will be equal to list SQL, and you will get first record's first field's value (according to kDBConnection::GetOne logic) as record count. 

I attached patch that fixes it. Also, it now checks for ANY whitespaces between SELECT and DISTINCT instead of one space.

count sql with distinct.patch

Related Tasks

INP-753 - Getting issue details... STATUS