Skip to content

Commit

Permalink
work around weird defaults when using utf8mb4 charset
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 3, 2024
1 parent f617820 commit e902c59
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,17 @@ private function getMySQLCaseSensitiveEncoding(): string

$params = $this->conn->getParams();
if (isset($params['defaultTableOptions']['collate'])) {
return $this->caseSensitiveEncoding = $params['defaultTableOptions']['collate'];
$this->caseSensitiveEncoding = (('utf8mb4' === $params['charset'] ?? null) && ('utf8_bin' === $params['defaultTableOptions']['collate']))
? 'utf8mb4_bin' // somehow dbal or mysql seem to hallucinate utf8_bin when it needs to be utf8mb4_bin
: $params['defaultTableOptions']['collate']
;

return $this->caseSensitiveEncoding;
}
if (!array_key_exists('charset', $params)) {
if (!array_key_exists('charset', $params) || !$params['charset']) {
throw new \InvalidArgumentException('For MySQL, the Doctrine dbal connection must have either "collate" or "charset" configured. Alternatively, you can set the encoding with '.__CLASS__.'::setCaseSensitiveEncoding().');
}
$charset = $params['charset'] ?? 'utf8';
$charset = $params['charset'];

return $this->caseSensitiveEncoding = 'binary' === $charset ? $charset : $charset.'_bin';
}
Expand Down Expand Up @@ -1696,7 +1701,7 @@ private function moveNode(string $srcAbsPath, string $destAbsPath): void
'path_prefix' => $srcAbsPath.'/%',
'path' => $srcAbsPath,
'workspace' => $this->workspaceName,
]);
]);

/*
* TODO: https://github.com/jackalope/jackalope-doctrine-dbal/pull/26/files#L0R1057
Expand Down

0 comments on commit e902c59

Please sign in to comment.