Skip to content

Commit

Permalink
Merge pull request #66 from graze/utf8mb3-diff-ignore
Browse files Browse the repository at this point in the history
charset & collation diff utf8mb3 as utf8
  • Loading branch information
rick-lam authored May 1, 2024
2 parents b4c7027 + c97c569 commit a89058f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Parse/CollationInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ public function setCharset($charset)
public function setCollation($collation)
{
$collation = strtolower($collation);
if (str_contains($collation, 'utf8mb3')) {
$collation = str_replace('utf8mb3', 'utf8', $collation);
$this->charset = str_replace('utf8mb3', 'utf8', $this->charset);
}

$charset = self::getCollationCharset($collation);
if (is_null($charset)) {
throw new RuntimeException("unknown collation '$collation'");
Expand Down
7 changes: 7 additions & 0 deletions src/Parse/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,13 @@ private function diffColumns(CreateTable $that)
// An existing column is being changed
$thisDefinition = $this->columns[$columnName]->toString($this->getCollation());
$thatDefinition = $that->columns[$columnName]->toString($that->getCollation());

if (str_contains($thisDefinition, 'utf8mb3')) {
$thisDefinition = str_replace('utf8mb3', 'utf8', $thisDefinition);
}
if (str_contains($thatDefinition, 'utf8mb3')) {
$thatDefinition = str_replace('utf8mb3', 'utf8', $thatDefinition);
}

// about to 'add' $columnName - get its location in the currently
// permuted state of the tabledef
Expand Down

0 comments on commit a89058f

Please sign in to comment.