mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-29 17:48:15 +08:00
Fix tests addCheck(), dropCheck() MariaDB. (#20174)
This commit is contained in:
@ -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'],
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user