Commit 4607e646 authored by jaapjansma's avatar jaapjansma
Browse files

Fixed #96: use INNER JOIN on custom fields when a filter is set.

parent 60359fcf
# Version 1.38 (not yet released)
* Fixed #96: use INNER JOIN on custom fields when a filter is set.
# Version 1.37.1
* Fixed regression bug with operator options in the filter.
......
......@@ -119,6 +119,13 @@ class SimpleJoin implements JoinInterface, SqlJoinInterface {
$this->type = $type;
}
/**
* @param $type
*/
public function setType($type) {
$this->type = $type;
}
/**
* @param WhereClauseInterface $clause
*
......
......@@ -23,4 +23,12 @@ interface SqlJoinInterface {
*/
public function getJoinClause(DataFlowDescription $sourceDataFlowDescription);
/**
* Set the type either be INNER, LEFT, RIGHT
*
* @param $type
* @return void
*/
public function setType($type);
}
\ No newline at end of file
......@@ -310,6 +310,18 @@ abstract class AbstractCivicrmEntitySource extends AbstractSource {
$customGroupDataFlow->addWhereClause(
new SimpleWhereClause($customGroupTableAlias, $spec->customFieldColumnName, $op, $values, $spec->type, TRUE)
);
switch ($op) {
case 'IN':
case '=':
// Change the custom fields join to INNER when the filter is a Is one of or Is equal
// Otherwise the custom fields will be included in the results but with an empty value.
// See: https://lab.civicrm.org/extensions/dataprocessor/-/issues/96
$join = $this->customGroupDataFlowDescriptions[$spec->customGroupName]->getJoinSpecification();
if ($join instanceof SqlJoinInterface) {
$join->setType('INNER');
}
break;
}
} else {
$this->ensureEntity();
$tableAlias = $this->getEntityTableAlias();
......@@ -504,7 +516,6 @@ abstract class AbstractCivicrmEntitySource extends AbstractSource {
$dataFlow = $this->ensureCustomGroup($originalFieldSpecification->customGroupTableName, $originalFieldSpecification->customGroupName);
if (!$dataFlow->getDataSpecification()->doesAliasExists($fieldSpecification->alias)) {
$dataFlow->getDataSpecification()->addFieldSpecification($fieldSpecification->alias, $fieldSpecification);
} else {
}
} elseif ($originalFieldSpecification) {
$this->ensureEntity();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment