Problem/Motivation
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
Example:
group 1 (AND each filter)
- content type = type1
- published = true
- field_1 = value1A
- field_2 = value2A (exposed)
- field_3 = value3A (exposed)
OR
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:
views_handler
views_handler_filter
views_handler_filter_in_operator
views_handler_filter_many_to_one
views_handler_filter_field_list
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
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1989588-manual-interdiff-1-4.txt | 2.77 KB | mradcliffe |
#4 | 1989588-respect-filter-group-4.patch | 3.63 KB | mradcliffe |
|
Comments
Comment #1
solotandem CreditAttribution: solotandem commentedThe 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.
Comment #2
mradcliffeI confirmed this, and the patch still applies to 7.x-3.x and works for me.
Comment #3
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch to handlers.inc does not apply to the latest views 7.x-3.x-dev and if still applicable needs reroll.
Comment #4
mradcliffeI've attached a re-roll. The patches are too old for interdiff to work so I've attached a manual diff of patches.
I'm still using the patch in #1.
Comment #5
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThanks @mradcliffe, the re-rolled patch #4 to handlers.inc applied cleanly to the latest views 7.x-3.x-dev and fixes this issue for me, but others may want to weigh in as well so I'll leave the status as is for now.