Views OR operator does everything but an OR operation

Created on 19 October 2021, over 3 years ago
Updated 5 June 2023, over 1 year ago

Problem/Motivation

When you use the OR operator in a filter group, it doesn't work. In fact, the query generated isn't even close to what it should be... Here is an example if set of filters I added to a view:

And then here is the resulting WHERE clause from the query:

WHERE 
(
  (
    // Content: Type (= On-demand)
    node__field_format.field_format_target_id = '29'
  )
) 
AND 
(
  (
    (
      // Content: Published (= Yes)
      "node_field_data"."status" = '1'
    )
    AND 
    (
      // Content: Content type (in Event, Training)
      "node_field_data"."type" IN ('event', 'training_session')
    )
  ) 
  AND
  (
    (
      // (field_date_and_location: Paragraph) Paragraph: Date Range (>= + 0 minutes)
      DATE_FORMAT((paragraphs_item_field_data_node__field_date_and_location__paragraph__field_date_range.field_date_range_value + INTERVAL -21600 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2021-10-19T18:53:48' + INTERVAL -21600 SECOND), '%Y-%m-%d\T%H:%i:%s')
    )
  )
)

This query isn't even remotely close to what I have it configured as... By my configurations, the expected WHERE clause should be

WHERE 
(
  (
    // Content: Published (= Yes)
    "node_field_data"."status" = '1'
  )
  AND 
  (
    // Content: Content type (in Event, Training)
    "node_field_data"."type" IN ('event', 'training_session')
  )
) 
AND 
(
  (
    // Content: Type (= On-demand)
    node__field_format.field_format_target_id = '29'
  ) 
  OR
  (
    // (field_date_and_location: Paragraph) Paragraph: Date Range (>= + 0 minutes)
    DATE_FORMAT((paragraphs_item_field_data_node__field_date_and_location__paragraph__field_date_range.field_date_range_value + INTERVAL -21600 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2021-10-19T18:53:48' + INTERVAL -21600 SECOND), '%Y-%m-%d\T%H:%i:%s')
  )
)

Steps to reproduce

Create a filter group using the `AND` operator, then `AND` that filter group with another filter group that uses the `OR` operator

Proposed resolution

Unknown, the WHERE clause is so far from what it should be I have no idea where to even start

๐Ÿ› Bug report
Status

Postponed: needs info

Version

9.5

Component
Viewsย  โ†’

Last updated about 1 hour ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024