From a0342dbece7fd500f04fcdb982f754306c4417cc Mon Sep 17 00:00:00 2001
From: Jaap Jansma <jaap.jansma@civicoop.org>
Date: Mon, 21 Oct 2024 10:23:16 +0200
Subject: [PATCH] Fixed issue with certain multi value fields on the filter
 configuration of a data source.

---
 CHANGELOG.md                                              | 1 +
 Civi/DataProcessor/Source/AbstractCivicrmEntitySource.php | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 64062163..b7143c90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
 # Version 1.116 (not yet released)
 
+* Fixed issue with certain multi value fields on the filter configuration of a data source.
 * Fixed issue with navigation menu.
 
 # Version 1.115
diff --git a/Civi/DataProcessor/Source/AbstractCivicrmEntitySource.php b/Civi/DataProcessor/Source/AbstractCivicrmEntitySource.php
index b2feb385..d8150161 100644
--- a/Civi/DataProcessor/Source/AbstractCivicrmEntitySource.php
+++ b/Civi/DataProcessor/Source/AbstractCivicrmEntitySource.php
@@ -10,6 +10,7 @@ use Civi\DataProcessor\DataFlow\CombinedDataFlow\SubqueryDataFlow;
 use Civi\DataProcessor\DataFlow\MultipleDataFlows\JoinInterface;
 use Civi\DataProcessor\DataFlow\MultipleDataFlows\SimpleNonRequiredJoin;
 use Civi\DataProcessor\DataFlow\MultipleDataFlows\SqlJoinInterface;
+use Civi\DataProcessor\DataFlow\SqlDataFlow\MultiValueFieldWhereClause;
 use Civi\DataProcessor\DataFlow\SqlDataFlow\PureSqlStatementClause;
 use Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause;
 use Civi\DataProcessor\DataFlow\SqlTableDataFlow;
@@ -337,7 +338,12 @@ abstract class AbstractCivicrmEntitySource extends AbstractSource {
       } else {
         $this->ensureEntity();
         $tableAlias = $this->getEntityTableAlias();
-        $this->entityDataFlow->addWhereClause(new SimpleWhereClause($tableAlias, $spec->name,$op, $values, $spec->type, TRUE));
+        if ($spec->isMultiValueField()) {
+          $clause = new MultiValueFieldWhereClause($tableAlias, $spec->name, $op, $values, $spec->type, TRUE);
+        } else {
+          $clause = new SimpleWhereClause($tableAlias, $spec->name,$op, $values, $spec->type, TRUE);
+        }
+        $this->entityDataFlow->addWhereClause($clause);
         $this->addFilterToAggregationDataFlow($spec, $op, $values);
       }
     }
-- 
GitLab