diff --git a/modules/node/node.module b/modules/node/node.module
index 9e20234..dda432e 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -3307,7 +3307,13 @@ function _node_query_node_access_alter($query, $type) {
         $field = 'entity_id';
       }
       $subquery->where("$nalias.$field = na.nid");
-      $query->exists($subquery);
+      // Attach the subquery to entity conditions for entities or to the query
+      // itself for nodes
+      if ($type == 'entity') {
+        $entity_conditions->exists($subquery);
+      } else {
+        $query->exists($subquery);
+      }
     }
   }
 
