The issue is to do with taxonomy arguments combined with relationships. I have a node view set up to return a list of nodes of a specific content type (done via a filter) that have a relationship to another content type, with fields being displayed from both the main content type and the related content type. This works fine, the bug comes up when I introduce a taxonomy argument that is tied to the related content type - for example, list all nodes of content type student that have a related node teacher where the teacher node belongs to a given taxonomy term. The correct nodes are retrieved, however they are duplicated for every taxonomy term that the related node is associated with, regardless of vocabulary. So, if a teacher node was associated with subjects (subjects being one vocabulary) Math and Science and grades (grades being another vocab) 9 and 10, and the term Science was passed into the view as an argument, each student node related to that one teacher would be displayed 4 times in the view.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | exported_view.txt | 9.07 KB | mtovey |
Comments
Comment #1
dawehnerCould you please export the view? So its easier to see, what you did.
Comment #2
mtovey commentedSure, I've attached the exported view in a text file. Let me know if you need any further information. Thanks.
Comment #3
merlinofchaos commentedCan you paste the query this view produces in the Preview?
Comment #4
mtovey commentedFollowing is a sample query produced by the view, when passing in a taxonomy term argument. Let me know if you need anything further. Thanks.
----------------------
SELECT node.nid AS nid,
node.title AS node_title,
node_data_field_docket.field_docket_value AS node_data_field_docket_field_docket_value,
node.type AS node_type,
node.vid AS node_vid,
node_data_field_docket.field_petitioner_value AS node_data_field_docket_field_petitioner_value,
node_data_field_docket.field_respondent_value AS node_data_field_docket_field_respondent_value,
node_data_field_decision.field_decision_value AS node_data_field_decision_field_decision_value,
node_data_field_decision.delta AS node_data_field_decision_delta,
node_data_field_granted.field_granted_value AS node_data_field_granted_field_granted_value,
node_data_field_granted.delta AS node_data_field_granted_delta,
node_node_data_field_case_node_data_field_argument.field_argument_value AS node_node_data_field_case_node_data_field_argument_field_argument_value
FROM node node
LEFT JOIN content_field_case node_data_field_case ON node.vid = node_data_field_case.vid
INNER JOIN node node_node_data_field_case ON node_data_field_case.field_case_nid = node_node_data_field_case.nid
LEFT JOIN term_node node_node_data_field_case__term_node ON node_node_data_field_case.vid = node_node_data_field_case__term_node.vid
LEFT JOIN term_node node_node_data_field_case_node_node_data_field_case__term_node ON node_node_data_field_case.vid = node_node_data_field_case_node_node_data_field_case__term_node.vid
INNER JOIN term_data node_node_data_field_case__term_data ON node_node_data_field_case__term_node.tid = node_node_data_field_case__term_data.tid
LEFT JOIN content_type_case node_data_field_docket ON node.vid = node_data_field_docket.vid
LEFT JOIN content_field_decision node_data_field_decision ON node.vid = node_data_field_decision.vid
LEFT JOIN content_field_granted node_data_field_granted ON node.vid = node_data_field_granted.vid
LEFT JOIN content_field_argument node_node_data_field_case_node_data_field_argument ON node_node_data_field_case.vid = node_node_data_field_case_node_data_field_argument.vid AND node_node_data_field_case_node_data_field_argument.delta = 0
WHERE (node.type in ('media_item')) AND (UPPER(node.title) LIKE UPPER('%argument%')) AND (node_node_data_field_case__term_data.name = '1988')
ORDER BY node_node_data_field_case_node_data_field_argument_field_argument_value DESC
Comment #5
merlinofchaos commentedI know that you marked this issue as being against Views 2.8, but that *really* looks like #648438: Relationship aliases not recorded, leading to bogus JOINs when adding certain sorts which is fixed in Views 2.8 -- are you absolutely sure you have Views 2.8?
Comment #6
mtovey commentedAfter checking, I found that Views 2.6 was installed. However, after upgrading to 2.8, the issue still remains. Following is the query that is produced under 2.8
--------------------------------------------------------------------------------------------------
SELECT node.nid AS nid,
node.title AS node_title,
node_data_field_docket.field_docket_value AS node_data_field_docket_field_docket_value,
node.type AS node_type,
node.vid AS node_vid,
node_data_field_docket.field_petitioner_value AS node_data_field_docket_field_petitioner_value,
node_data_field_docket.field_respondent_value AS node_data_field_docket_field_respondent_value,
node_data_field_decision.field_decision_value AS node_data_field_decision_field_decision_value,
node_data_field_decision.delta AS node_data_field_decision_delta,
node_data_field_granted.field_granted_value AS node_data_field_granted_field_granted_value,
node_data_field_granted.delta AS node_data_field_granted_delta,
node_node_data_field_case_node_data_field_argument.field_argument_value AS node_node_data_field_case_node_data_field_argument_field_argument_value
FROM node node
LEFT JOIN content_field_case node_data_field_case ON node.vid = node_data_field_case.vid
INNER JOIN node node_node_data_field_case ON node_data_field_case.field_case_nid = node_node_data_field_case.nid
LEFT JOIN term_node node_node_data_field_case__term_node ON node_node_data_field_case.vid = node_node_data_field_case__term_node.vid
LEFT JOIN term_node node_node_data_field_case_node_node_data_field_case__term_node ON node_node_data_field_case.vid = node_node_data_field_case_node_node_data_field_case__term_node.vid
INNER JOIN term_data node_node_data_field_case__term_data ON node_node_data_field_case__term_node.tid = node_node_data_field_case__term_data.tid
LEFT JOIN content_type_case node_data_field_docket ON node.vid = node_data_field_docket.vid
LEFT JOIN content_field_decision node_data_field_decision ON node.vid = node_data_field_decision.vid
LEFT JOIN content_field_granted node_data_field_granted ON node.vid = node_data_field_granted.vid
LEFT JOIN content_field_argument node_node_data_field_case_node_data_field_argument ON node_node_data_field_case.vid = node_node_data_field_case_node_data_field_argument.vid AND node_node_data_field_case_node_data_field_argument.delta = 0
WHERE (node.type in ('media_item')) AND (UPPER(node.title) LIKE UPPER('%argument%')) AND (node_node_data_field_case__term_data.name = '1988')
ORDER BY node_node_data_field_case_node_data_field_argument_field_argument_value DESC
Comment #7
merlinofchaos commentedHm. Be sure to clear all your caches. With 2.8 that query should have one less join.
Comment #8
mtovey commentedI've cleared my caches (via the 'Flush all Caches' admin function) and double checked that Views 2.8 is installed on our site. I'm still seeing the original issue where multiple entries are being generated based on the total number of taxonomy terms the related node belongs to. Let me know if you need any further info re this.
Comment #9
esmerel commentedComment #10
dawehner@mtovey
Did you cleared views caches too on admin/build/views/tools
Alterernative you could check whether this is still an issue.
Comment #11
iamjon commentedsetting this to postponed
Comment #12
iamjon commented