Fix COUNT(DISTINCT x) queries from getting corrupted in Sqlserver.

Add into the tower of hacks that is the SQL generation and stop breaking
COUNT(DISTINCT foo) style queries. Previously these would be converted
into DISTINCT COUNT(foo) which will give the non-distinct results.
This commit is contained in:
mark_story 2013-10-29 23:01:20 -04:00
parent 0f8dae55c9
commit 16be5722ba

View file

@ -278,7 +278,7 @@ class Sqlserver extends DboSource {
for ($i = 0; $i < $count; $i++) {
$prepend = '';
if (strpos($fields[$i], 'DISTINCT') !== false) {
if (strpos($fields[$i], 'DISTINCT') !== false && strpos($fields[$i], 'COUNT') === false) {
$prepend = 'DISTINCT ';
$fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i]));
}