--- includes/query.inc.orig	2009-11-03 14:48:53.000000000 +0100
+++ includes/query.inc	2009-11-03 14:59:47.000000000 +0100
@@ -116,14 +116,18 @@
    */
   function set_distinct($value = TRUE) {
     if (!(isset($this->no_distinct) && $value)) {
-      // Hack in a check to see if node_access is going to add its own DISTINCT
-      // and break this query.
-      // See http://drupal.org/node/284392 for the core bug.
+      // Hack in a check to see if node_access is going to add its own
+      // DISTINCT and break this query. See
+      // http://drupal.org/node/284392 for the core bug.
+      // 
+      // We want to bypass views distinct code if this bug will be
+      // triggered. So if the base field is nid and there is a node
+      // access module, bypass views distinct code.
       //
-      // We want to bypass views distinct code if this bug will be triggered so
-      // if the base table is node and there is a node access module, bypass
-      // views distinct code.
-      if ($this->base_table != 'node' || !node_access_view_all_nodes()) {
+      // Since this bug has different implications for Drupal
+      // pre-6.14 and 6.14, we need to include a check for Drupal's
+      // version.
+      if (version_compare(VERSION, '6.14', '<') && $this->base_field == 'nid' && !node_access_view_all_nodes()) {
         $this->distinct = FALSE;
       }
       else {
@@ -900,6 +904,19 @@
    *   Provide a countquery if this is true, otherwise provide a normal query.
    */
   function query($get_count = FALSE) {
+    // Hack in a check to see if node_access is not going to add its
+    // own DISTINCT and break this query. See
+    // http://drupal.org/node/284392 for the core bug.
+    //
+    // We want to force the DISTINCT value if the base field is nid
+    // and there is a node_access module.
+    //
+    // Since this bug has different implications for Drupal pre-6.14
+    // and 6.14, we need to include a check for Drupal's version.
+    if (version_compare(VERSION, '6.14', '>=') && $this->base_field == 'nid' && !node_access_view_all_nodes()) {
+      $this->distinct = TRUE;
+    }
+
     // Check query distinct value.
     if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) {
       if (!empty($this->fields[$this->base_field])) {
