Steps to reproduce the problem:
- create a content type using "list" fields: List (integer), List (float), List (text), and Boolean
- create a view using the content type as base table
- add two filters on the same list field using the "Is one of" operator
- separate the filters into two groups
- connect the filter groups by "OR"; connect the filters in each group by "AND"
- optionally, expose the filters

group 1 (AND each filter)
- content type = type1
- published = true
- field_1 = value1A
- field_2 = value2A (exposed)
- field_3 = value3A (exposed)
group 2 (AND each filter)
- content type = type1
- published = true
- field_1 = value1B
- field_2 = value2B (exposed)
- field_3 = value3B (exposed)

The join clauses for field_1 are:
INNER JOIN {field_data_field_1} field_data_field_1 ON
node.nid = field_data_field_1.entity_id AND
(field_data_field_1.entity_type = 'node' AND field_data_field_1.deleted = '0')

LEFT JOIN {field_data_field_2} field_data_field_2 ON
node.nid = field_data_field_2.entity_id AND
field_data_field_2.field_2_value != '1'

In the example, the second join clause is unnecessary and its presence causes the results to exclude desired values. It occurs because the code does not respect the filter groups when determining the join clause.

Proposed resolution

Respect the filter groups when determining the join clause for this type of filter.

Class hierarchy for a "list" module field:


The offending code is in three methods of views_many_to_one_helper class: ensure_my_table(), summary_join(), and add_table.

Remaining tasks

Review, write tests.

User interface changes


API changes


#1 1989588-respect-filter-group.patch4 KBsolotandem
PASSED: [[SimpleTest]]: [MySQL] 1,627 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


solotandem’s picture

Status: Active » Needs review
4 KB
PASSED: [[SimpleTest]]: [MySQL] 1,627 pass(es). View

The attached patch implements group checking for the many-to-one filter handler. Similar code appears in the many-to-one argument handler, but I did not test this and it will await a later patch.

mradcliffe’s picture

I confirmed this, and the patch still applies to 7.x-3.x and works for me.