I've been seeing the following error in the dblog fairly frequently for several releases now:
Not unique table/alias: 'na' query: SELECT DISTINCT(n.nid), bt.name as biblio_type_name, b.biblio_year, b.biblio_date FROM node n left join biblio b on n.vid=b.vid inner join biblio_types bt on b.biblio_type=bt.tid INNER JOIN node_access na ON na.nid = n.nid INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 1 AND na.realm = 'node_privacy_byrole_role') OR (na.gid = 0 AND na.realm = 'node_privacy_byrole_user') OR (na.gid = 1 AND na.realm = 'workflow_access') OR (na.gid = 0 AND na.realm = 'workflow_access_owner') OR (na.gid = 0 AND na.realm = 'og_public'))) AND ( (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 1 AND na.realm = 'node_privacy_byrole_role') OR (na.gid = 0 AND na.realm = 'node_privacy_byrole_user') OR (na.gid = 1 AND na.realm = 'workflow_access') OR (na.gid = 0 AND na.realm = 'workflow_access_owner') OR (na.gid = 0 AND na.realm = 'og_public'))) AND ( (n.type='biblio' ) AND (n.status = 1 ) ))ORDER BY b.biblio_year , b.biblio_date LIMIT 10 in /var/www/live/drupal/sites/all/modules/biblio/biblio.module on line 1813.
Any ideas of how to fix it? I notice that node_access is being joined twice, could that be it? Thanks!

Comments

rjerome’s picture

Hi Dane,

You hit the nail on the head there, I just noticed that db_rewrite_sql() is being called twice on the query, so that's why node_access is joined twice.

I think if you just delete line 1813 in the biblio module everything should be fine. I'm not even sure why that's there, but I suspect a cut'n'paste error.

Ron.

function biblio_filter_feed($query, $terms = NULL, $rss_info = NULL) {
  $base = variable_get('biblio_base', 'biblio');
  $result = db_query(db_rewrite_sql($query));  //         <----------------------DELETE THIS LINE
  $channel['title'] = $rss_info['title'];
  $channel['link'] = url($base . $rss_info['link'], array('absolute' => TRUE));
  $channel['description'] = $rss_info['description'];
  $nids = array();
  $result = db_query($query, $terms);
  while ($row = db_fetch_object($result)) {
    $nids[] = $row->nid;
  }
  node_feed($nids, $channel);
}
danepowell’s picture

Status: Active » Reviewed & tested by the community

That appears to fix the problem, indeed. Thanks!

rjerome’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS... http://drupal.org/cvs?commit=317402

Ron.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.