Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's a view and error.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data_node__draggableviews_structure_weight_coalesce' in 'order clause'
SELECT node.title AS node_title, node.nid AS nid, taxonomy_term_data_node.weight AS taxonomy_term_data_node_weight, 'node' AS field_data_taxonomy_vocabulary_3_node_entity_type, COALESCE(taxonomy_term_data_node__draggableviews_structure.weight, 10000) AS taxonomy_term_data_node__draggableviews_structure_weight_coa
FROM
{node} node
LEFT JOIN (SELECT td.*, tn.nid AS nid
FROM
{taxonomy_term_data} td
LEFT JOIN {taxonomy_vocabulary} tv ON td.vid = tv.vid
LEFT JOIN {taxonomy_index} tn ON tn.tid = td.tid
WHERE (tv.machine_name IN ('product_types')) ) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid
LEFT JOIN {draggableviews_structure} taxonomy_term_data_node__draggableviews_structure ON taxonomy_term_data_node.tid = taxonomy_term_data_node__draggableviews_structure.entity_id AND taxonomy_term_data_node__draggableviews_structure.view_name = 'taxonomy_term' AND taxonomy_term_data_node__draggableviews_structure.view_display = 'page' AND taxonomy_term_data_node__draggableviews_structure.args = 'null'
WHERE (( (node.status = '1') AND (node.type IN ('product')) ))
ORDER BY taxonomy_term_data_node_weight ASC, taxonomy_term_data_node__draggableviews_structure_weight_coalesce ASC
LIMIT 30 OFFSET 0
The field alias taxonomy_term_data_node__draggableviews_structure_weight_coalesce is 66 chars long and shorted (probably by views) to COALESCE(taxonomy_term_data_node__draggableviews_structure.weight, 10000) AS taxonomy_term_data_node__draggableviews_structure_weight_coa
Comment | File | Size | Author |
---|---|---|---|
#11 | draggableviews-unknown_column_orderby_alias-1787764-11.patch | 1.29 KB | iStryker |
#8 | draggableviews-table_alias-1787764-8.patch | 1.35 KB | iStryker |
#1 | 1787764-draggableviews-field-alias.patch | 769 bytes | andypost |
Comments
Comment #1
andypostSimplest fix just to remove suffix
Also probably better to rename module's table to more shorter
{draggableviews_structure}
to{draggableviews}
Comment #2
podarok2 #1 or even from
{draggableviews_structure}
to{dw}
Comment #3
iStryker CreditAttribution: iStryker commentedI do not understand why its getting cut off. 66 is a random. Common database numbers are
L=2^X-1
, like 31,63,127,255.This sounds more like a Views problem than a draggableviews issue
I do not like the #1 patch. It's a fix for your query, as it is shorter, but it might not be to someone else.
If there is a hard limit to the length in the view then:
Comment #4
dpovshed CreditAttribution: dpovshed commentedIMHO module tables should have prefix like views_drag_ .
This naming placed them near main views tables and clearly distinct they roots and purpose.
Comment #5
cr0ss CreditAttribution: cr0ss commentedRegarding the latest version 2.0 of the draggableviews module issues with aliases are solved by following:
Nothing to fix further.
Comment #6
andypostActually this is a views bug-o-feature #571548: Identifiers longer than 63 characters are truncated, causing Views to break on Postgres
@cr0ss what this code for?
Comment #7
andypostBug was introduced in #1660508: 'New items appear bottom of the list' option fails in PostgreSQL because of COALESCE function
Comment #8
iStryker CreditAttribution: iStryker commentedOk this patch changes all the tables alias from 'draggableviews_structure' to 'dv'. The only problem is that it break every view using draggableviews.
I believe a
draggableviews_update_72XX()
hook can solve this, where it does a regular expression change from 'draggableviews_structure' to 'dv' for all the views.The other option that springs to my mind is what was done in 7.x-1.x. In the previous version it did a check and replacement if the relationships were broken.
Comment #9
andypost@iStryker not sure about possibility hook_update() for that some views could be packed to features so moving them to DB is no-go. But yes we need a proper way to generate alias for table relation
Comment #10
iStryker CreditAttribution: iStryker commentedThank you @andypost. I never though about features.
Here at University of Waterloo we use features extensively. Correct me if I am wrong...On the local development, if we update the views in the hook_update(), then all of the features will show as overridden (as all the code is in the database). They will need to be re-rolled. If you revert them, then there is no way to fix them, unless you do them manually (as you cannot re-run an update_hook).
On Staging/Live, without the new features pushed to it, when you run the update_hook, then all of the views will break, as none of the views are saved to the database.
If you push the features to Staging/Live, the views will break.
If you push the features to Staging/Live and update your draggableviews from 7.x-2.0 to a version where #8 is committed, then everything will work
If you push the features to Staging/Live and update your draggableivews from 7.x-2.0 to a version where #8 is committed, and run update.php, everything works.
So the only way not to break features is to add a miss relationship catch like what was kinda done in 7.x-1.x-dev.
Other suggestion is to roll this out in 7.x-3.0 and say screw everyone with features.
Comment #11
iStryker CreditAttribution: iStryker commentedOk I believe I actually found the problem.
So Views truncates the field to 60 characters in length. We do not truncate the orderby field, therefore they do not match.
Now if we call add_orderby() function instead of add_field() & set the orderby ourselfs (see attached patch), views will add the field and validate the alias for us.
From views/plugins/views_plugin_query_default.inc
Patch Attached. This does not break features. Ignore #8 Patch.
Committed e7e2d4e
I believe this does not need to be backported to 6.x as Coalese was added to 7.x-2.x. Reopen if I am wrong.
Comment #12
iStryker CreditAttribution: iStryker commentedPatch #11 also add the orderby order if 'New items at bottom' is unchecked. Now for the sort order display, you cannot change this (as it is removed), however for the page display you can not change this. It still defaults to ASC.
Comment #13
iStryker CreditAttribution: iStryker commented[repeat of #12]