diff --git a/includes/database.inc b/includes/database.inc index e6ad4baba80dd7f8b2018ed956111db72ba13c1a..3931fda1ed29157d1259643301ab91e86e1564b2 100644 --- a/includes/database.inc +++ b/includes/database.inc @@ -231,7 +231,7 @@ function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $ list($join, $where, $distinct) = _db_rewrite_sql($query, $primary_table, $primary_field, $args); if ($distinct) { - $field_to_select = 'DISTINCT($primary_table .'.'. $primary_field)'; + $field_to_select = 'DISTINCT('. $primary_table .'.'. $primary_field .')'; // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT). $query = preg_replace('/(SELECT.*)('. $primary_table .'\.)?(?<!DISTINCT\()(?<!DISTINCT\('. $primary_table .'\.)'. $primary_field .'(.*FROM)/AUsi', '\1'. $field_to_select .'\3', $query); }