Index: views_query.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/views/views_query.inc,v retrieving revision 1.59 diff -u -r1.59 views_query.inc --- views_query.inc 3 Dec 2006 17:28:17 -0000 1.59 +++ views_query.inc 11 Dec 2006 22:25:49 -0000 @@ -310,9 +310,18 @@ if ($alias) { $a = " AS $this->use_alias_prefix$alias"; } - if (!in_array("$table$field$a", $this->fields)) { - $this->fields[] = "$table$field$a"; + foreach ($this->fields as $k => $f) { + if (preg_match("/((DISTINCT)[(])?{$table}{$field}([)])?({$a})?/", $f, $matches)) { + if (isset($matches[4]) && $matches[4] != $a) { + drupal_set_message(t('%field is already in fields list with a different alias', array('%field' => "$table$field")), 'error'); + } + else { + $this->fields[$k] = "{$matches[1]}$table$field{$matches[3]}$a"; + } + return; + } } + $this->fields[] = "$table$field$a"; } /*