Skip to content

Commit

Permalink
Exporting Contacts using "Export PRIMARY fields" and "Merge Household…
Browse files Browse the repository at this point in the history
… Members into their Households" produces db error
  • Loading branch information
monishdeb committed Apr 2, 2018
1 parent 09aaec1 commit eeb6d43
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 141 deletions.
4 changes: 3 additions & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -4708,10 +4708,11 @@ public static function filterCountryFromValuesIfStateExists(&$formValues) {
* @param array $selectClauses
* @param array $groupBy - Columns already included in GROUP By clause.
* @param string $aggregateFunction
* @param bool $appendAlias - Append select column alias as it's name itself
*
* @return string
*/
public static function appendAnyValueToSelect($selectClauses, $groupBy, $aggregateFunction = 'ANY_VALUE') {
public static function appendAnyValueToSelect($selectClauses, $groupBy, $aggregateFunction = 'ANY_VALUE', $appendAlias = FALSE) {
if (!CRM_Utils_SQL::disableFullGroupByMode()) {
$groupBy = array_map('trim', (array) $groupBy);
$aggregateFunctions = '/(ROUND|AVG|COUNT|GROUP_CONCAT|SUM|MAX|MIN|IF)[[:blank:]]*\(/i';
Expand All @@ -4722,6 +4723,7 @@ public static function appendAnyValueToSelect($selectClauses, $groupBy, $aggrega
$val = ($aggregateFunction == 'GROUP_CONCAT') ?
str_replace($selectColumn, "$aggregateFunction(DISTINCT {$selectColumn})", $val) :
str_replace($selectColumn, "$aggregateFunction({$selectColumn})", $val);
$val .= $appendAlias ? " as $selectColumn " : '';
}
}
}
Expand Down
Loading

0 comments on commit eeb6d43

Please sign in to comment.