CRM-21364 Fix Dedupe fillTable Query when running in full groupBy Mode
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 2 Nov 2017 23:34:05 +0000 (10:34 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 2 Nov 2017 23:34:05 +0000 (10:34 +1100)
CRM/Dedupe/BAO/RuleGroup.php

index b3b0ef128aadc9b8e9777e23f1e4d76b944f7f24..7bd63eec8f24ce879d0662d886e60353c3528d58 100644 (file)
@@ -196,13 +196,13 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
     if ($this->params && !$this->noRules) {
       $tempTableQuery = "CREATE TEMPORARY TABLE dedupe (id1 int, weight int, UNIQUE UI_id1 (id1)) ENGINE=InnoDB";
       $insertClause = "INSERT INTO dedupe (id1, weight)";
-      $groupByClause = "GROUP BY id1";
+      $groupByClause = "GROUP BY id1, weight";
       $dupeCopyJoin = " JOIN dedupe_copy ON dedupe_copy.id1 = t1.column WHERE ";
     }
     else {
       $tempTableQuery = "CREATE TEMPORARY TABLE dedupe (id1 int, id2 int, weight int, UNIQUE UI_id1_id2 (id1, id2)) ENGINE=InnoDB";
       $insertClause = "INSERT INTO dedupe (id1, id2, weight)";
-      $groupByClause = "GROUP BY id1, id2";
+      $groupByClause = "GROUP BY id1, id2, weight";
       $dupeCopyJoin = " JOIN dedupe_copy ON dedupe_copy.id1 = t1.column AND dedupe_copy.id2 = t2.column WHERE ";
     }
     $patternColumn = '/t1.(\w+)/';