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 2, 2024
1 parent f617820 commit d6fd808
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,12 @@ 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)) {
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().');
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 d6fd808

Please sign in to comment.