Problem/Motivation
Proper Views support for Non-Node-entities was added here: #2400211: Add Views support for non-node entity types
The Workflow Views give wrong results in the following case:
- Using Entity references:
1) Create content type A
2) Create content type B
3) Make content type B reference content type A
4) Create workflow used for content type A
5) Create view that select content type B, add relationship to content type A, add field current comment for content type A (with relationships)
- Using Node Revisions:
1) Create a view for 'Content revisions'
-> The Workflow Views give an error "Unknown column 'node.nid' in 'where clause'".
- Using Node Revisions:
1) Create some content with workflow_field
2) for a node, change status several times, add a revision, again change state a few times.
3) show the results in /workflow page (the 'dashboard').
- Using multiple Workflow Fields per entity type:
1) Create some content with workflow_field1 and workflow_field2;
2) create a view;
3) only the field with the latest transition is shown.
Proposed resolution
Change the table join in function workflow_views_views_data_alter() in file workflow_views/workflow_views.views.inc
Remaining tasks
The Patch in #16 is a good start. It will show data based on any entity type.
Patch #16 solves the second case, but still gives wrong results in the following casse:
Extend the path in #16 to work correctly with all Transition key fields: revision_id, field_name, language
Original report by VovkaTS
I had this problem "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'workflow_node.stamp' in 'on clause'" when i want to get Current comment.
Comments
Comment #1
VovkaTS commentedComment #2
nancydruCorrecting status
Comment #3
johnvI cannot reproduce your error.
I installed Workflow and Workflow Views. Table 'workflow_node' contains the column 'stamp' as expected.
I created a Content View, added all 'Workflow...' fields. The View works a expected.
Is it because you want to use the 'fancy' field to field join from #1090432 ?
Comment #4
igor.ro commented@johnv to reproduce follow this steps.
1) Create content type A
2) Create content type B
3) Make content type B reference content type A
4) Create workflow used for content type A
5) Create view that select content type B, add relationship to content type A, add field current comment for content type A (with relationships)
workflow_node works ok for base content type and does not work for content type with relationships, because that code does not use alias
Comment #5
johnvReassigning.
Comment #6
johnvFor another issue, the following, apparently wrong join was removed in #2147535: Add a "Last transition" views filter :
'extra' => 'workflow_node.stamp = workflow_node_current.stamp AND workflow_node.nid = workflow_node_current.nid',Your code contains more changes, but I trust the problem is gone with version 7.x-2.x
Comment #7
igor.ro commentedThis code
'left_query' => " SELECT max(hid) FROM {workflow_node_history} where nid = node.nid and sid != old_sid ",would not work either with views relationships.
Comment #8
johnvOK, open again, then.
Comment #9
johnvI'm testing this with Entity Reference to create the reference from A to B. (both having a Workflow Node.)
I do not get your error, but indeed: only the data from the main entity is shown. The reference entity B also shows the data from entity A.
The 'history comments' are fine.
Comment #10
johnvYour patch contains a lot of code for xss, indicating it only solves the 'comment' part.
There is also an error with the other fields of a transition: 'current status', 'time', etc.
IMO the problem should be addressed using the correct table-joins, solving this for all fields.
Comment #11
igor.ro commentedThat is the problem. If you add node title field for A and for B, in views you expected to have different values, not the same for main entity.
I'll check patch again to exclude xss.
Comment #12
igor.ro commentedIf you will confirm that you will merge the same fixes for other fields, we will create patch for them also.
Comment #13
johnvYes, I am happy to correct all fields.
I think the problem is in the tables, not the subfields themselves.
P.S. I just made another commit #2149121: Restructure workflow_views_views_data(). on the same code. Please be sure to use the latest code.
Comment #14
johnvComment #15
tuchoI wrote a work-around for the problem using "Workflow current" with views relationships, as described in #7.
It searches for the last state of every node using a "table formula" with subqueries, instead of using the views_join_subquery handler.
Comment #16
tuchoMy patch from #2074859-15: Views displaying wrong data when using references/revisions/multiple fields have a bug when using more than a workflow field in a content type.
When grouping the rows from workflow_node_history to obtain the latest state of every node, my original query removes all workflow fields except the last one which has a state change.
Now I group by nid and field_name, so the query obtains the latest state from every workflow field of every node.
Comment #17
johnvComment #18
VenDG commentedThe patch in #16 fixes the "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node.nid' in 'where clause'" error that was present in my views after updating to 7.x-2.x.
Comment #19
johnvPatch #6 seems like a step in the good direction. However, I get some wrong results (added in summary).
Also, the code base has changed ITMT.
Can someone take a look at #16 using latest dev-version?
Comment #20
johnvComment #21
VenDG commentedI redid #16 against the stable version - 7.x-2.5. The error I was receiving is gone.
Comment #22
johnvThanks, @VenDG. We still need some db_query guru to solve the problems in the Issue Summary.
Comment #23
Mouna Hammami commentedHello,
I was experimented the same problem when trying to get the workflow's new state of revisions.
For this reason, i have improved the patch #21 to support node_revision entities.
You can try this in this patch(D7 version). It works well for me
Have fun !
Comment #24
johnvSee alos:
#2645368: SQL error: Unknown column 'workflow_node_history.entity_type' on a relation
#2645374: SQL error: Views field broken with relation: Workflow current: State name
Comment #26
johnvThanks all! #23 was committed.
I leave this issue open, until I checked/tested all open problems/sub-issues in the Issue Summary.
Comment #27
johnv