InterOperator is always set to "AND" for the subgroups of a condition

Created on 4 October 2023, over 1 year ago
Updated 12 October 2023, over 1 year ago

Problem/Motivation

I encountered a problem in the build() method of the EudonetQueryCondition class, where the InterOperator is always set to "AND" regardless of the InterOperator specified in the query.

Steps to reproduce

  1. Add a first andGroup() to a query,
  2. Then added a subgroup orGroup() to this first group

Code Example:

    $query->addFields($fields + $dateFields);
    $andGroup = $query->andGroup();
    foreach ($dateFields as $dateField) {
      $orGroup = $query->orGroup();
      $orGroup->condition($dateField, "2022/04/25 15:00:00", '>');
      $orGroup->condition($dateField, "2022/12/25 15:00:00", '<');
      $andGroup->conditionGroup($orGroup);
    }
    $query->conditionGroup($andGroup);

The output of $query->build() always has InterOperator set to 1 for the subgroups of a condition even if I add this subgroup with orGroup().

Proposed resolution

In the EudonetQueryCondition class, in the build() method, the InterOperator is hardcoded to "AND":
$build['InterOperator'] = Eudonet::INTER_OPERATORS['AND'];

The suggested correction is to set it based on the group's specified interOperator:
$build['InterOperator'] = Eudonet::INTER_OPERATORS[$this->interOperator];

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada samsylve

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

Comments & Activities

Production build 0.71.5 2024