Skip to content

Commit

Permalink
Fix case when groups are mixed case #348
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Aug 26, 2024
1 parent 109a680 commit b89e837
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,22 @@ function xmldb_tool_excimer_upgrade($oldversion) {
$dbman->change_field_precision($table, $field);

// Find all non-unique page groups and remove duplicates.
$sql = "
SELECT pgroups.id, pgroups.name, pgroups.month, pgroups.fuzzycount
FROM {tool_excimer_page_groups} pgroups
JOIN (
SELECT name, month
FROM {tool_excimer_page_groups}
GROUP BY name, month
HAVING COUNT(*) > 1
) dupl ON pgroups.name = dupl.name AND pgroups.month = dupl.month
ORDER BY pgroups.name, pgroups.month, pgroups.fuzzycount DESC
";
$sql = " SELECT pgroups.id,
LOWER(pgroups.name),
pgroups.month,
pgroups.fuzzycount
FROM {tool_excimer_page_groups} pgroups
JOIN (
SELECT LOWER(name),
month
FROM {tool_excimer_page_groups}
GROUP BY LOWER(name),
month
HAVING COUNT(*) > 1
) dupl ON LOWER(pgroups.name) = LOWER(dupl.name) AND pgroups.month = dupl.month
ORDER BY LOWER(pgroups.name),
pgroups.month,
pgroups.fuzzycount DESC";
$duplicates = $DB->get_records_sql($sql);

if (!empty($duplicates)) {
Expand Down

0 comments on commit b89e837

Please sign in to comment.