Unverified Commit 45ea287c authored by belgattitude's avatar belgattitude Committed by Luís Cobucci

Unescaping re-added, support limited to schema introspection (#2850 will bring...

Unescaping re-added, support limited to schema introspection (#2850 will bring more complete coverage)
parent 7f2cd3d3
......@@ -218,8 +218,9 @@ class MySqlSchemaManager extends AbstractSchemaManager
* to distinguish them from expressions (see MDEV-10134).
* - CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE are stored in information_schema
* as current_timestamp(), currdate(), currtime()
* - Note: Quoted 'NULL' is not enforced by Maria, it is technically possible to have
* - Quoted 'NULL' is not enforced by Maria, it is technically possible to have
* null in some circumstances (see https://jira.mariadb.org/browse/MDEV-14053)
* - \' is always stored as '' in information_schema (normalized)
*
* @link https://mariadb.com/kb/en/library/information-schema-columns-table/
* @link https://jira.mariadb.org/browse/MDEV-13132
......@@ -232,7 +233,11 @@ class MySqlSchemaManager extends AbstractSchemaManager
return null;
}
if ($columnDefault[0] === "'") {
return preg_replace('/^\'(.*)\'$/', '$1', $columnDefault);
return stripslashes(
str_replace("''", "'",
preg_replace('/^\'(.*)\'$/', '$1', $columnDefault)
)
);
}
switch ($columnDefault) {
case 'current_timestamp()':
......
......@@ -446,4 +446,25 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diff = $comparator->diffTable($table, $onlineTable);
self::assertFalse($diff, "Tables should be identical with column defauts time and date.");
}
/**
* Ensure default values (un-)escaping is properly done by mysql platforms.
* The test is voluntarily relying on schema introspection due to current
* doctrine limitations. Once #2850 is landed, this test can be removed.
*/
public function testEnsureDefaultsAreUnescapedFromSchemaIntrospection() : void
{
$platform = $this->_sm->getDatabasePlatform();
$this->_conn->query('DROP TABLE IF EXISTS test_column_defaults_with_create');
$default = "a\\0b\\'c\"d\te\\Zf\\\\g''h";
$sql = "CREATE TABLE test_column_defaults_with_create(
col1 VARCHAR(255) NULL DEFAULT {$platform->quoteStringLiteral($default)}
)";
$this->_conn->query($sql);
$onlineTable = $this->_sm->listTableDetails("test_column_defaults_with_create");
self::assertSame($default, $onlineTable->getColumn('col1')->getDefault());
}
}
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