I am working on a view that needs to get results from one of two places. The first is a series of taxonomy terms that are each referenced by a field on a specific node type. The second is a separate set of fields but references to the same terms held in a field collection that is on the same content type. The idea is to have a primary and a secondary way to include information in a list.

If I clone my view and only do the first half it works perfectly. If I only do the second half it also works perfectly. However when I put them together with an OR operator in between the two sets of possible data I do not get any data back.

Here is the code that the view generates.

/* Display: Inventory/SlaughterPage */
$handler = $view->new_display('page', 'Inventory/SlaughterPage', 'page_4');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Inventory/Slaughter';
$handler->display->display_options['display_description'] = 'Cattle Inventory/Production Page';
$handler->display->display_options['defaults']['query'] = FALSE;
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Content: Additional Sections (field_additional_sections) */
$handler->display->display_options['relationships']['field_additional_sections_value']['id'] = 'field_additional_sections_value';
$handler->display->display_options['relationships']['field_additional_sections_value']['table'] = 'field_data_field_additional_sections';
$handler->display->display_options['relationships']['field_additional_sections_value']['field'] = 'field_additional_sections_value';
$handler->display->display_options['relationships']['field_additional_sections_value']['delta'] = '-1';
/* Relationship: Content: File (field_member_only_file:fid) */
$handler->display->display_options['relationships']['field_member_only_file_fid']['id'] = 'field_member_only_file_fid';
$handler->display->display_options['relationships']['field_member_only_file_fid']['table'] = 'field_data_field_member_only_file';
$handler->display->display_options['relationships']['field_member_only_file_fid']['field'] = 'field_member_only_file_fid';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['filter_groups']['operator'] = 'OR';
$handler->display->display_options['filter_groups']['groups'] = array(
  1 => 'AND',
  2 => 'AND',
);
$handler->display->display_options['defaults']['filters'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Sub-Section (field_sub_section) */
$handler->display->display_options['filters']['field_sub_section_tid']['id'] = 'field_sub_section_tid';
$handler->display->display_options['filters']['field_sub_section_tid']['table'] = 'field_data_field_sub_section';
$handler->display->display_options['filters']['field_sub_section_tid']['field'] = 'field_sub_section_tid';
$handler->display->display_options['filters']['field_sub_section_tid']['value'] = array(
  1 => '1',
);
$handler->display->display_options['filters']['field_sub_section_tid']['group'] = 1;
$handler->display->display_options['filters']['field_sub_section_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_sub_section_tid']['vocabulary'] = 'sub_section';
/* Filter criterion: Content: File Location (field_file_location_field) */
$handler->display->display_options['filters']['field_file_location_field_tid']['id'] = 'field_file_location_field_tid';
$handler->display->display_options['filters']['field_file_location_field_tid']['table'] = 'field_data_field_file_location_field';
$handler->display->display_options['filters']['field_file_location_field_tid']['field'] = 'field_file_location_field_tid';
$handler->display->display_options['filters']['field_file_location_field_tid']['value'] = array(
  16 => '16',
);
$handler->display->display_options['filters']['field_file_location_field_tid']['group'] = 1;
$handler->display->display_options['filters']['field_file_location_field_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_file_location_field_tid']['vocabulary'] = 'file_location';
/* Filter criterion: Content: Cattle Sub-Sections (field_file_sub_section) */
$handler->display->display_options['filters']['field_file_sub_section_tid']['id'] = 'field_file_sub_section_tid';
$handler->display->display_options['filters']['field_file_sub_section_tid']['table'] = 'field_data_field_file_sub_section';
$handler->display->display_options['filters']['field_file_sub_section_tid']['field'] = 'field_file_sub_section_tid';
$handler->display->display_options['filters']['field_file_sub_section_tid']['value'] = array(
  45 => '45',
);
$handler->display->display_options['filters']['field_file_sub_section_tid']['group'] = 1;
$handler->display->display_options['filters']['field_file_sub_section_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_file_sub_section_tid']['vocabulary'] = 'file_sub_sections';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_1']['id'] = 'status_1';
$handler->display->display_options['filters']['status_1']['table'] = 'node';
$handler->display->display_options['filters']['status_1']['field'] = 'status';
$handler->display->display_options['filters']['status_1']['value'] = '1';
$handler->display->display_options['filters']['status_1']['group'] = 2;
/* Filter criterion: Field collection item: Content Sub Section (field_content_sub_section) */
$handler->display->display_options['filters']['field_content_sub_section_tid']['id'] = 'field_content_sub_section_tid';
$handler->display->display_options['filters']['field_content_sub_section_tid']['table'] = 'field_data_field_content_sub_section';
$handler->display->display_options['filters']['field_content_sub_section_tid']['field'] = 'field_content_sub_section_tid';
$handler->display->display_options['filters']['field_content_sub_section_tid']['relationship'] = 'field_additional_sections_value';
$handler->display->display_options['filters']['field_content_sub_section_tid']['value'] = array(
  1 => '1',
);
$handler->display->display_options['filters']['field_content_sub_section_tid']['group'] = 2;
$handler->display->display_options['filters']['field_content_sub_section_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_content_sub_section_tid']['vocabulary'] = 'sub_section';
/* Filter criterion: Field collection item: Secondary Location (field_secondary_location) */
$handler->display->display_options['filters']['field_secondary_location_tid']['id'] = 'field_secondary_location_tid';
$handler->display->display_options['filters']['field_secondary_location_tid']['table'] = 'field_data_field_secondary_location';
$handler->display->display_options['filters']['field_secondary_location_tid']['field'] = 'field_secondary_location_tid';
$handler->display->display_options['filters']['field_secondary_location_tid']['relationship'] = 'field_additional_sections_value';
$handler->display->display_options['filters']['field_secondary_location_tid']['value'] = array(
  16 => '16',
);
$handler->display->display_options['filters']['field_secondary_location_tid']['group'] = 2;
$handler->display->display_options['filters']['field_secondary_location_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_secondary_location_tid']['vocabulary'] = 'file_location';
/* Filter criterion: Field collection item: Cattle Sub-Section (field_cattle_sub_section) */
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['id'] = 'field_cattle_sub_section_tid';
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['table'] = 'field_data_field_cattle_sub_section';
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['field'] = 'field_cattle_sub_section_tid';
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['relationship'] = 'field_additional_sections_value';
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['value'] = array(
  45 => '45',
);
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['group'] = 2;
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_cattle_sub_section_tid']['vocabulary'] = 'file_sub_sections';
$handler->display->display_options['path'] = 'members/spreadsheets/cattle/InventorySlaughter';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Inventory/Slaughter';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['name'] = 'main-menu';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;

Thanks,
Steve

CommentFileSizeAuthor
#1 image.png29.16 KBskessler
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skessler’s picture

FileSize
29.16 KB

I can also include a screen shot of what the filters look like in Views.

Screen shot of views filters

John Pitcairn’s picture

skessler’s picture

The patch in #1766338: Incorrect filter group OR behavior, LEFT JOIN changed to INNER JOIN does not work for me but I think they are related. I will update this post when I know more.

Thanks John!

senzaesclusiva’s picture

Hello guys
This problem affects also 6.x-3
This is a simple query:

SELECT node.title AS node_title,
node.nid AS nid
 FROM node node 
 WHERE (node.type in ('corporates'))
    AND ((node.title) LIKE ('A%'))
    AND ((node.title) LIKE ('B%'))
   ORDER BY node_title ASC

But would be:

SELECT node.title AS node_title,
node.nid AS nid
 FROM node node 
 WHERE (node.type in ('corporates'))
    AND ((node.title) LIKE ('A%'))
    OR ((node.title) LIKE ('B%'))
   ORDER BY node_title ASC

Your solution may be ported for 6.x-3 version?

danielphenry’s picture

I had this issue also but it did indeed turn out to be caused by: #1766338: Regression: Incorrect filter group OR behavior, LEFT JOIN changed to INNER JOIN

From the thread looks like if you select the "reduce duplicates' checkbox on your fields it may resolve the issue.