API module assumes the primary table in api_db_rewrite_query() is always {node}
| Project: | API |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Hi everyone
I am new to drupal, so please let me know if I couldn't explain the following problem properly.
I have a site in which I installed project and project issue tracking. My users created issues in the site without any problem. After installing api (http://drupal.org/project/api), the following message was displayed when my users wanted to search or create issues.
user warning: Unknown column 'p.type' in 'where clause' query: SELECT DISTINCT(p.nid) FROM project_projects p INNER JOIN node_access na ON na.nid = p.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'tac_lite') OR (na.gid = 135 AND na.realm = 'tac_lite') OR (na.gid = 132 AND na.realm = 'tac_lite') OR (na.gid = 181 AND na.realm = 'tac_lite') OR (na.gid = 153 AND na.realm = 'tac_lite') OR (na.gid = 40 AND na.realm = 'tac_lite') OR (na.gid = 137 AND na.realm = 'tac_lite') OR (na.gid = 45 AND na.realm = 'tac_lite') OR (na.gid = 12 AND na.realm = 'tac_lite') OR (na.gid = 8 AND na.realm = 'tac_lite') OR (na.gid = 4 AND na.realm = 'tac_lite') OR (na.gid = 5 AND na.realm = 'tac_lite') OR (na.gid = 6 AND na.realm = 'tac_lite') OR (na.gid = 13 AND na.realm = 'tac_lite') OR (na.gid = 114 AND na.realm = 'tac_lite') OR (na.gid = 117 AND na.realm = 'tac_lite') OR (na.gid = 119 AND na.realm = 'tac_lite') OR (na.gid = 17 AND na.realm = 'tac_lite') OR (na.gid = 14 AND na.realm = 'tac_lite'))) AND (p.type <> 'api') AND ( p.uri = 'partotech_documentation')
in my-drupal-path/sites/all/modules/project_issue/includes/issue_node_form.inc on line 159.
When I disabled api module, the error message disappeared. I don't exactly know what the problem with api and project issue is.
I will be really thankful for your help.

#1
Here's the problem:
api.module, end of DRUPAL-6--1 branch, lines 591-595:
<?phpfunction api_db_rewrite_sql($query, $primary_table, $primary_field) {
if ($primary_field == 'nid') {
return array('where' => $primary_table . ".type <> 'api'");
}
}
?>
Just because a query is being generated that uses nid as the primary field doesn't mean that table is {node} and contains a "type" column. Seems like we should test
$primary_table == 'n'in there, too.#2
#586202: SQL error in comment.module cause by api_db_rewrite_sql()
#3
Thank you very much for your help. I really appreciate you for your attention.