I tried or-ing my 3.x view today but got unexpected results.

Wanted to filter on (content_type=X) OR (content_type=Y AND Y_cck_field = Z).

This will only show Y_cck_field = Z, when I watched the query views generated I noticed that it did an INNER JOIN on Y_CCK_field, so I guess that's why I got no content_type X in my results.

This a bug or should I rearrange my filters in another way ?

Tnx

Comments

dagmar’s picture

Assigned: Unassigned » merlinofchaos

Yes this is a problem with the current implementation of views.

The solution could be include a relationship to the same node table to allow something like (node1.content_type=Y AND node1.Y_cck_field = Z) OR (node2.content_type=X) but I'm afraid this is not current possible with existent relationships provided by views.

Lets ask to merlinofchaos.

merlinofchaos’s picture

That's odd. CCK fields are usually left joined.

dagmar’s picture

Status: Active » Postponed (maintainer needs more info)

@HnLn: Please export your view.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
mallezie’s picture

Assigned: merlinofchaos » Unassigned
Status: Closed (cannot reproduce) » Active

Sorry to reopen this issue, but i found exactly the same issuu with views 6.x.3.x.dev

I have a filter:

Group 1:
node type in (A,B,C,D)

AND

Group2
( node_type_A_field = value OR
node_type_B_field = value OR
node_type_C_field = value OR
node_type_D_field = value )

Does an inner join which excludes results when only node_type_A has that field, and so on.

If you wan't more info....

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

... see http://drupal.org/node/935984#comment-3652918

In general it would be nice to have a way to reproduce the issue without having the need to click around for 15minutes.

mallezie’s picture

StatusFileSize
new17.1 KB

It's the view with name 'doen'.

It returns this SQL

SELECT node.nid AS nid FROM node node  INNER JOIN content_type_kinderknutseltip node_data_field_kinderknutseltip_indekijke  ON node.vid = node_data_field_kinderknutseltip_indekijke.vid  INNER JOIN content_type_ateljeebanjee node_data_field_ateljeebanjee_indekijker  ON node.vid = node_data_field_ateljeebanjee_indekijker.vid  INNER JOIN content_type_knutseltip node_data_field_knutseltip_indekijker  ON node.vid = node_data_field_knutseltip_indekijker.vid  INNER JOIN content_type_workshop node_data_field_workshop_indekijker  ON node.vid = node_data_field_workshop_indekijker.vid  WHERE ( node.type in ('ateljeebanjee', 'kinderknutseltip', 'knutseltip', 'workshop'))  AND  ((node_data_field_kinderknutseltip_indekijke.field_kinderknutseltip_indekijke_value = '1')  OR (node_data_field_ateljeebanjee_indekijker.field_ateljeebanjee_indekijker_value = '1')  OR  (node_data_field_knutseltip_indekijker.field_knutseltip_indekijker_value = '1')  OR  (node_data_field_workshop_indekijker.field_workshop_indekijker_value = '1'))

I changed the SQL through a views hoof to replace the inner joins with left joins, which gives the correct output.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Active
Mark Theunissen’s picture

I'm also seeing this issue. My view has:

(
Content type = 'Announcement'
)

OR

(
Content type = 'File'
AND
Has taxonomy term = 'Term'
)

I only get back the nodes of type 'File' with term 'Term'.

Further debugging shows that the problem is the INNER JOIN, changing this to a left join fixes it.

dmenefee’s picture

StatusFileSize
new1.58 KB
new11.7 KB

Seeing the same problem. I've attached the exported view and the SQL query resulting from it.

StG’s picture

StatusFileSize
new26.21 KB
new1.82 KB

Subscribing. I have exactly the same issue with this part of SQL: INNER JOIN users node_node__users ON node_node.uid = node_node__users.uid

StG’s picture

I've investigated this issue a little bit, and I think I found the reason.
In my view I use content types: research_paper and review. The connection between them is based on a user reference cck-field (it's the reviewer). The view results in a list of papers assigned to a reviewer. Two filters are needed here:

  1. Author of review is the current user OR
  2. Assigned papers not yet reviewd (node id of review IS NULL)

These two filters works very well separately, but together not. The first filter creates this part of SQL: INNER JOIN users node_node__users ON node_node.uid = node_node__users.uid (every node has its author) and this clause remains the same in the query when I use both filters. Thats why it returns only partial result.
I guess a custom filter handler is needed here, but I don't really know how to begin...

johnpitcairn’s picture

I have similar behavior in 7.x-3.5, but in 7.x-3.3+173-dev the SQL query was indeed using LEFT JOIN for the optional filter field. See #1766338: Incorrect filter group OR behavior, LEFT JOIN changed to INNER JOIN.

geek-merlin’s picture

Status: Active » Closed (duplicate)
johnpitcairn’s picture

Not so sure it's a dup. All of these issues pre-date the commit that broke things in #1766338: Incorrect filter group OR behavior, LEFT JOIN changed to INNER JOIN