Skip to content

Commit

Permalink
fixup! MDL-83153 core: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Sep 18, 2024
1 parent d1bcfa4 commit 5449594
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/db/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ function upgrade_change_binary_column_to_int(
// Copy the values from the old field to the new field.
$sql = 'UPDATE {' . $tablename . '}
SET ' . $fieldname . ' = 1
WHERE ' . $DB->sql_compare_text($tmpfieldname) . ' = :truefieldvalue';
WHERE ' . $DB->sql_compare_text($tmpfieldname) . ' = ' . $DB->sql_compare_text(':truefieldvalue');
$DB->execute($sql, ['truefieldvalue' => 1]);

// Drop the old field.
Expand Down
7 changes: 4 additions & 3 deletions lib/tests/upgradelib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1724,12 +1724,13 @@ public function test_upgrade_change_binary_column_to_int(
$field = $columns[$fieldname];
$this->assertFalse($field->binary);

// Verify that the renamed old field has now been removed.
$this->assertArrayNotHasKey("tmp$fieldname", $columns);

// Confirm that the values for the converted column ar ethe same.
$records = $DB->get_fieldset($tmptablename, 'id', [$fieldname => 1]);
print_object($records);
$this->assertEqualsCanonicalizing($ones, $records);

// Verify that the renamed old field has now been removed.
$this->assertArrayNotHasKey("tmp$fieldname", $columns);
}

// Cleanup.
Expand Down

0 comments on commit 5449594

Please sign in to comment.