How to reproduice :
In a view, add an exposed filter (in my case on term reference field ex: field_myvocabulary). Select all vocabulary terms, check multiple and reduce options.
Add the same field as filter but not exposed (always field_myvocabulary). Select all vocabulary terms.
Put the filter which is not exposed before the filter which is exposed.
Now we have filters:
- Content : My vocabulary
- Content : My vocabulary (exposed)

I make this to select all the content which have one of this terms selected and let my visitor choose specifics filters.

In exposed form, when i check 1 or more term filter, i have results (everything is fine). But if i check 1 or more filters, i never see contents with my last term. If i check nothing, i can see them.
Exposed filters (cross on selected)
[ ] Term 1
[ ] Term 2
[ ] Term 3
Everything is ok, i can see content with term 3 and/or term 2 and/or term 1.
SQL :

SELECT node.title AS node_title, node.nid AS nid
FROM 
{node} node
INNER JOIN {field_data_field_myvocabulary} field_data_field_myvocabulary ON node.nid = field_data_field_myvocabulary.entity_id AND (field_data_field_myvocabulary.entity_type = 'node' AND field_data_field_myvocabulary.deleted = '0')
WHERE (field_data_field_myvocabulary.field_myvocabulary_tid IN  ('1', '2', '3')) 
ORDER BY node_title ASC

[ ] Term 1
[X] Term 2
[ ] Term 3
Everything is ok, i can see content with term 2.
SQL :

SELECT node.title AS node_title, node.nid AS nid
FROM 
{node} node
INNER JOIN {field_data_field_myvocabulary} field_data_field_myvocabulary ON node.nid = field_data_field_myvocabulary.entity_id AND (field_data_field_myvocabulary.entity_type = 'node' AND field_data_field_myvocabulary.deleted = '0')
LEFT JOIN {field_data_field_myvocabulary} field_data_field_myvocabulary2 ON node.nid = field_data_field_myvocabulary2.entity_id AND field_data_field_myvocabulary2.field_myvocabulary_tid != '3'
WHERE (field_data_field_myvocabulary.field_myvocabulary_tid IN  ('1', '2', '3')
 AND (field_data_field_myvocabulary2.field_myvocabulary_tid = '2') 
ORDER BY node_title ASC

Looking at SQL, we can see we now LEFT JOIN on the exposed filter and specify we want term 2.
But we can also see a miscellaneous condition on LEFT JOIN : field_data_field_myvocabulary2.field_myvocabulary_tid != '3'
Why this test ? The problem is that test is also on SQL when i check term 3

[ ] Term 1
[ ] Term 2
[X] Term 3
No results.
SQL :

SELECT node.title AS node_title, node.nid AS nid
FROM 
{node} node
INNER JOIN {field_data_field_myvocabulary} field_data_field_myvocabulary ON node.nid = field_data_field_myvocabulary.entity_id AND (field_data_field_myvocabulary.entity_type = 'node' AND field_data_field_myvocabulary.deleted = '0')
LEFT JOIN {field_data_field_myvocabulary} field_data_field_myvocabulary2 ON node.nid = field_data_field_myvocabulary2.entity_id AND field_data_field_myvocabulary2.field_myvocabulary_tid != '3'
WHERE (field_data_field_myvocabulary.field_myvocabulary_tid IN  ('1', '2', '3')
 AND (field_data_field_myvocabulary2.field_myvocabulary_tid = '3') 
ORDER BY node_title ASC

Reading SQL, it's easy to see that we cannot have results with this request (request select fields field_data_field_myvocabulary2.field_myvocabulary_tid != '3' and after that where field_data_field_myvocabulary2.field_myvocabulary_tid = '3')

So why field_data_field_myvocabulary2.field_myvocabulary_tid != '3' is added on SQL request ? I put nowhere a restriction like that

This bug is also reproduced with option field.

Comments

GoZ’s picture

I see the same bug report on d6 : http://drupal.org/node/928936

MustangGB’s picture

Status: Active » Closed (outdated)