Occurs if the {term_node} has a 'weight' column. If a developer adds a 'weight' column to the {term_node} table, the following warning (or similar) will show on certain pages.
user warning: Column 'weight' in order clause is ambiguous query: SELECT t.tid, t.name FROM master_term_data t INNER JOIN master_term_node r ON r.tid = t.tid WHERE t.vid = 7 AND r.nid = 84549 ORDER BY weight LIMIT 0, 1 in /var/www/example.com/sites/all/modules/contrib/pathauto/pathauto.module on line 115.
The fix is easy. Simply change 'ORDER BY weight' to 'ORDER BY t.weight' on line 115 of pathauto.module.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | pathauto-534818.patch | 1.24 KB | mdevrel |
Comments
Comment #1
gregglesWhy would a developer add that column?
That said, we probably should use table prefixes on all columns just to be safe.
Comment #2
mdevrel commentedIn our case, we are using taxonomy terms as image galleries. The weight is used to keep track and enable re-ordering of the images within each gallery. Each image node can belong to more than one gallery, so term_node becomes the logical table to add the weight field since term_node is already used in the query to get the images for a gallery. Simply add term_node.weight to the order-by clause:
Regardless, as you mentioned, it is best-practice to use table prefixes on all columns in any query pulling from more than one table.
Comment #3
mdevrel commentedHere's a patch that should fix the issue.
Comment #4
dave reidSide note, having the alias 'r' for the {term_node} table is very wonky. Can we do {term_node} tn so this is less ambiguous?
Comment #5
dave reidApplied #3 to all three CVS branches. Thanks!
http://drupal.org/cvs?commit=330272
http://drupal.org/cvs?commit=330274
http://drupal.org/cvs?commit=330276