Unverified Commit 5d4f9335 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch 'bpo/2.9/#3393' into 2.9

parents 62dacc09 b18f63cc
...@@ -18,7 +18,6 @@ use function stripslashes; ...@@ -18,7 +18,6 @@ use function stripslashes;
use function strpos; use function strpos;
use function strtok; use function strtok;
use function strtolower; use function strtolower;
use function trim;
/** /**
* Schema manager for the MySql RDBMS. * Schema manager for the MySql RDBMS.
...@@ -305,25 +304,28 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -305,25 +304,28 @@ class MySqlSchemaManager extends AbstractSchemaManager
$table->addOption('autoincrement', $tableOptions['AUTO_INCREMENT']); $table->addOption('autoincrement', $tableOptions['AUTO_INCREMENT']);
} }
$table->addOption('comment', $tableOptions['TABLE_COMMENT']); $table->addOption('comment', $tableOptions['TABLE_COMMENT']);
$table->addOption('create_options', $this->parseCreateOptions($tableOptions['CREATE_OPTIONS']));
if ($tableOptions['CREATE_OPTIONS'] === null) { return $table;
return $table; }
}
$createOptionsString = trim($tableOptions['CREATE_OPTIONS']); /**
* @return string[]|true[]
*/
private function parseCreateOptions(string $string) : array
{
$options = [];
$createOptions = []; if ($string === '') {
return $options;
}
if ($createOptionsString !== '') { foreach (explode(' ', $string) as $pair) {
foreach (explode(' ', $createOptionsString) as $option) { $parts = explode('=', $pair, 2);
[$createOption, $value] = explode('=', $option);
$createOptions[$createOption] = $value; $options[$parts[0]] = $parts[1] ?? true;
}
} }
$table->addOption('create_options', $createOptions); return $options;
return $table;
} }
} }
...@@ -502,6 +502,7 @@ ENGINE InnoDB ...@@ -502,6 +502,7 @@ ENGINE InnoDB
ROW_FORMAT COMPRESSED ROW_FORMAT COMPRESSED
COMMENT 'This is a test' COMMENT 'This is a test'
AUTO_INCREMENT=42 AUTO_INCREMENT=42
PARTITION BY HASH (col1)
SQL; SQL;
$this->connection->query($sql); $this->connection->query($sql);
...@@ -511,7 +512,10 @@ SQL; ...@@ -511,7 +512,10 @@ SQL;
self::assertEquals('utf8_general_ci', $onlineTable->getOption('collation')); self::assertEquals('utf8_general_ci', $onlineTable->getOption('collation'));
self::assertEquals(42, $onlineTable->getOption('autoincrement')); self::assertEquals(42, $onlineTable->getOption('autoincrement'));
self::assertEquals('This is a test', $onlineTable->getOption('comment')); self::assertEquals('This is a test', $onlineTable->getOption('comment'));
self::assertEquals(['row_format' => 'COMPRESSED'], $onlineTable->getOption('create_options')); self::assertEquals([
'row_format' => 'COMPRESSED',
'partitioned' => true,
], $onlineTable->getOption('create_options'));
} }
public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment