Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 500 characters in body
Source Link
user1359
  • 3.9k
  • 10
  • 60
  • 103

I have a view with FILTER CRITERIA set. I have three groups, each joined by ANDs, with the criteria within each group ORed. The final group are two taxonomy terms, meaning I want my query to return nodes that have one term or the other. No node will have both of the tags set.

enter image description here enter image description here

However, when I see the SQL in the preview, the terms seem are connected by a AND. enter image description here

WHERE (((node__field_event_categories.field_event_categories_target_id = '434')) AND ((node__field_event_categories2.field_event_categories_target_id = '212'))) AND ((taxonomy_index.status = '1') AND (((DATE_FORMAT((node__field_date_range.field_date_range_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s'))) OR ((DATE_FORMAT((node__field_date_range.field_date_range_end_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s')))))

This causes my query not to return any results.

I've tried removing each tid, one by one, and when one is missing I get results. So I'm thinking I should get both sets of results when they are set to OR.

To make sure I was reading the SQL correctly, I ran it through a pretty-printer:

enter image description here

To double check, I exported the views config, to see what the yaml said about the WHERE clause, and it all seems to be OR within the groups:

enter image description here

I even re-imported the configuration from this yaml, but I still get the same results.

How can I get my taxonomy criteria to function using OR?

Edit In the course of troubleshooting, I tried to simplify the filter criteria. I removed everything, all groups and criteria. This is what I have now:

enter image description here

enter image description here

enter image description here

This is Drupal 8.6.2. We just updated, so I'm wondering if this is a new bug.

I have a view with FILTER CRITERIA set. I have three groups, each joined by ANDs, with the criteria within each group ORed. The final group are two taxonomy terms, meaning I want my query to return nodes that have one term or the other. No node will have both of the tags set.

enter image description here enter image description here

However, when I see the SQL in the preview, the terms seem are connected by a AND. enter image description here

WHERE (((node__field_event_categories.field_event_categories_target_id = '434')) AND ((node__field_event_categories2.field_event_categories_target_id = '212'))) AND ((taxonomy_index.status = '1') AND (((DATE_FORMAT((node__field_date_range.field_date_range_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s'))) OR ((DATE_FORMAT((node__field_date_range.field_date_range_end_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s')))))

This causes my query not to return any results.

I've tried removing each tid, one by one, and when one is missing I get results. So I'm thinking I should get both sets of results when they are set to OR.

To make sure I was reading the SQL correctly, I ran it through a pretty-printer:

enter image description here

To double check, I exported the views config, to see what the yaml said about the WHERE clause, and it all seems to be OR within the groups:

enter image description here

I even re-imported the configuration from this yaml, but I still get the same results.

How can I get my taxonomy criteria to function using OR?

I have a view with FILTER CRITERIA set. I have three groups, each joined by ANDs, with the criteria within each group ORed. The final group are two taxonomy terms, meaning I want my query to return nodes that have one term or the other. No node will have both of the tags set.

enter image description here enter image description here

However, when I see the SQL in the preview, the terms seem are connected by a AND. enter image description here

WHERE (((node__field_event_categories.field_event_categories_target_id = '434')) AND ((node__field_event_categories2.field_event_categories_target_id = '212'))) AND ((taxonomy_index.status = '1') AND (((DATE_FORMAT((node__field_date_range.field_date_range_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s'))) OR ((DATE_FORMAT((node__field_date_range.field_date_range_end_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s')))))

This causes my query not to return any results.

I've tried removing each tid, one by one, and when one is missing I get results. So I'm thinking I should get both sets of results when they are set to OR.

To make sure I was reading the SQL correctly, I ran it through a pretty-printer:

enter image description here

To double check, I exported the views config, to see what the yaml said about the WHERE clause, and it all seems to be OR within the groups:

enter image description here

I even re-imported the configuration from this yaml, but I still get the same results.

How can I get my taxonomy criteria to function using OR?

Edit In the course of troubleshooting, I tried to simplify the filter criteria. I removed everything, all groups and criteria. This is what I have now:

enter image description here

enter image description here

enter image description here

This is Drupal 8.6.2. We just updated, so I'm wondering if this is a new bug.

Source Link
user1359
  • 3.9k
  • 10
  • 60
  • 103

Views filter criteria groups OR not working?

I have a view with FILTER CRITERIA set. I have three groups, each joined by ANDs, with the criteria within each group ORed. The final group are two taxonomy terms, meaning I want my query to return nodes that have one term or the other. No node will have both of the tags set.

enter image description here enter image description here

However, when I see the SQL in the preview, the terms seem are connected by a AND. enter image description here

WHERE (((node__field_event_categories.field_event_categories_target_id = '434')) AND ((node__field_event_categories2.field_event_categories_target_id = '212'))) AND ((taxonomy_index.status = '1') AND (((DATE_FORMAT((node__field_date_range.field_date_range_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s'))) OR ((DATE_FORMAT((node__field_date_range.field_date_range_end_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s')))))

This causes my query not to return any results.

I've tried removing each tid, one by one, and when one is missing I get results. So I'm thinking I should get both sets of results when they are set to OR.

To make sure I was reading the SQL correctly, I ran it through a pretty-printer:

enter image description here

To double check, I exported the views config, to see what the yaml said about the WHERE clause, and it all seems to be OR within the groups:

enter image description here

I even re-imported the configuration from this yaml, but I still get the same results.

How can I get my taxonomy criteria to function using OR?