Fix tests addCheck(), dropCheck() MariaDB. (#20174)

This commit is contained in:
Wilmer Arambula
2024-05-30 11:54:15 -04:00
committed by GitHub
parent e92466bbba
commit 42e6524413
5 changed files with 131 additions and 40 deletions

View File

@ -205,8 +205,10 @@ SQL;
*/
protected function loadTableChecks($tableName)
{
$version = $this->db->getServerVersion();
// check version MySQL >= 8.0.16
if (version_compare($this->db->getSlavePdo()->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.16', '<')) {
if (\stripos($version, 'MariaDb') === false && \version_compare($version, '8.0.16', '<')) {
throw new NotSupportedException('MySQL < 8.0.16 does not support check constraints.');
}
@ -230,17 +232,9 @@ SQL;
$tableRows = $this->normalizePdoRowKeyCase($tableRows, true);
foreach ($tableRows as $tableRow) {
$matches = [];
$columnName = null;
if (preg_match('/\(`?([a-zA-Z0-9_]+)`?\s*[><=]/', $tableRow['check_clause'], $matches)) {
$columnName = $matches[1];
}
$check = new CheckConstraint(
[
'name' => $tableRow['constraint_name'],
'columnNames' => [$columnName],
'expression' => $tableRow['check_clause'],
]
);